try
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ETHANConnectionString"].ConnectionString);
            SqlCommand comm = new SqlCommand();
            comm.Connection = conn;
            conn.Open();            string sqlwr = "update EMPBaseInfo set EMPName='" + TextBox2.Text.Trim() + "' where EMPID= 'ET-00002'";
            SqlCommand cmd = new SqlCommand(sqlwr, conn);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
            Response.Write("<script>alert('保存成功!')</script>");
        }
        catch
        {
            Response.Write("<script>alert('error!')</script>");
        }更新不了  没有报错   也没有catch error
郁闷啊难道还有权限的问题?
能insert  应该不至于权限问题吧 

解决方案 »

  1.   

    把sql单独摘出来放到数据库执行以下update试试,也可以断点调试
      

  2.   

    调试的时候吧 sqlwr  中的字符串放到 sqlserver 里跑一下就知道了
      

  3.   

    sql里 update  没问题的
    textbox数值也是通过ET-00002获取的   再修改的
      

  4.   

    跑过了 先生   在SQL SRV里 怎么跑都是对的
      

  5.   

    try
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ETHANConnectionString"].ConnectionString);
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                conn.Open();            string sqlwr = "update EMPBaseInfo set EMPName='" + TextBox2.Text.Trim() + "' where EMPID= 'ET-00002'";
                SqlCommand cmd = new SqlCommand(sqlwr, conn);
                bool flag = cmd.ExecuteNonQuery() > 0 ? true : false;
                cmd.Dispose();
                conn.Close();
                if (flag)
                {
                    Response.Write("<script>alert('保存成功!')</script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('error!')</script>");
            }
    看它还弹不弹 了
      

  6.   

    发现了 ,   
    原来是前面Page_Load里
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ETHANConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select EMPName from [EMPBaseInfo] where EMPID='ET-00002'";
            string rstNM = string.Empty;
            conn.Open();
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    rstNM = Convert.ToString(reader["EMPName"]);
                }
            }
            conn.Close();
            TextBox2.Text = rstNM;
    获取了 sql信息,
    到后面  button3  click事件里
            try
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ETHANConnectionString"].ConnectionString);
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                conn.Open();            string sqlwr = "update EMPBaseInfo set EMPName='" + TextBox2.Text.Trim() + "' where EMPID= 'ET-00002'";
                SqlCommand cmd = new SqlCommand(sqlwr, conn);
                bool flag = cmd.ExecuteNonQuery() > 0 ? true : false;
                cmd.Dispose();
                conn.Close();
                if (flag)
                {
                    Response.Write("<script>alert('保存成功!')</script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('error!')</script>");
            }
    就不能更改,
    把前面那段page_load  里面 代码屏蔽掉  就可以更改了
    这为什么?
    获取信息之后 应是在内存里的噢   更改获取以后的数值  怎么就更改不了
      

  7.   

    Page_Load 代码写到
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    //你的代码
                }
           }
      

  8.   


            catch
            {
                Response.Write("<script>alert('error!')</script>");
            }去掉后,就会报错了,把它去掉后再调试
    好了,再加上,不然很难调试,不知那里错了
      

  9.   

    pageload 先于 event事件执行。
    所以你在pageload中又重新给textbox赋值了。
    请先认真了解下事件的执行顺序
      

  10.   

    把pageload里的那段代码放在
    if(!IsPostBack)
    {
    }
    里面去