protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {     
        string id = TextBox1.Text;  
        string cellphone = TextBox5.Text;
        string name = TextBox6.Text;
        string socialNum = TextBox7.Text;
        string email = TextBox8.Text;
        string sex = DropDownList1.SelectedValue.ToString();
        string zipcode = TextBox9.Text;
        string address = TextBox10.Text;        string SQL = "UPDATE users SET  u_name='" + name + "',u_cellphone='" + cellphone + "',";
        SQL += "u_socialNum='" + socialNum + "',u_email='" + email + "',u_sex='" + sex + "',u_zipcode='" + zipcode + "',u_address='" + address + "' WHERE u_id='" + id + "';";
        SqlConnection conn = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand(SQL, conn);        conn = new SqlConnection(connectionString);
        cmd = new SqlCommand(SQL, conn);
        SqlDataReader rd;
         
        try
        {
            conn.Open();
            rd = cmd.ExecuteReader();
            rd.Read();
            Response.Write("<script>alert('수정 완료되었습니다!!!');</script>");
            rd.Close();
           
        }
        catch (Exception error)
        {
             Response.Write("<script>alert('수정 실패되었습니다!!!');</script>");
        }
        finally
        {
            conn.Close();
        }点解修改按钮时 页面就变成个空白页面 这个修改函数部分哪里错了呢  谢谢 帮帮看下

解决方案 »

  1.   

    Response.Write("<script>alert('수정 완료되었습니다!!!');</script>");
    有这么调用脚本的么?
    用Page.ClientScript
      

  2.   

    把conn.Open();
                rd = cmd.ExecuteReader();//你只是读数据  你用update操作怎么可能读数据呢
                rd.Read();
                Response.Write("<script>alert('수정 완료되었습니다!!!');</script>");
                rd.Close();改为conn.Open();
                rd = cmd.ExecuteNonQuery();//这里是执行你的update语句,返回影响的行数
             
                Response.Write("<script>alert('수정 완료되었습니다!!!');</script>");
               
      

  3.   


    catch (Exception error)
            {
                 Response.Write("<script>alert('수정 실패되었습니다!!!');</script>");
            }中的Response.Write注释掉,你就能看到异常信息了。
    如果不想要客户看到异常信息,最好把异常发邮件到管理员,或者写log.吃掉是不可取的行为。
      

  4.   

    int i=0;
    i=cmd.ExecuteNonQuery();
    if(i>0)
    {
         Response.Write("<script>alert('수정 완료되었습니다!!!');</script>"); 
    }
    else
    {
         Response.Write("<script>alert('수정 실패되었습니다!!!');</script>");
    }
      

  5.   

     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {     
            string id = TextBox1.Text;  
            string cellphone = TextBox5.Text;
            string name = TextBox6.Text;
            string socialNum = TextBox7.Text;
            string email = TextBox8.Text;
            string sex = DropDownList1.SelectedValue.ToString();
            string zipcode = TextBox9.Text;
            string address = TextBox10.Text;        string SQL = "UPDATE users SET  u_name='" + name + "',u_cellphone='" + cellphone + "',";
            SQL += "u_socialNum='" + socialNum + "',u_email='" + email + "',u_sex='" + sex + "',u_zipcode='" + zipcode + "',u_address='" + address + "' WHERE u_id='" + id + "';";
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand(SQL, conn);        conn = new SqlConnection(connectionString);
            cmd = new SqlCommand(SQL, conn); 
             int i = 0;
              
            try
            {
                conn.Open();
                i = cmd.ExecuteNonQuery(); 
                if (i > 0)
                {
                    Response.Write("<script>alert('수정 완료되었습니다!!!');</script>");
                }
                else
                {
                   Response.Write("<script>alert('수정 실패되었습니다!!!');</script>");
                }
              // conn.Close();
               
            }
            catch (Exception error)
            {
                Response.Write(error.Message); 
            }
            finally
            {
                conn.Close();
            }
            我 这样修改之后为什么还是不行呢?