SSQL="update stu set 姓名= '" + textBox1.Text.Trim()+"' where ID='" + textBox2.Text.Trim()+"'";

解决方案 »

  1.   

    多看些例子吧,http://developer.51cto.com/art/200903/115491.htm
      

  2.   

    可以用where 条件 限制吧
      

  3.   

    变成字符串,输出如:update stu set 姓名= '张三' where ID='10’;,这个语句可直接在SQL数据库中进行查询,
      

  4.   

      SqlConnection mCnn = new SqlConnection();
                mCnn.ConnectionString = "Data Source=192.168.1.5;Database=Test;Uid=sa;Pwd=sa";
                mCnn.Open();
                string strSQL ="update stu set 姓名= '" + textBox1.Text.Trim()+"' where ID='" + textBox2.Text.Trim()+"'";
                SqlCommand cmd = new SqlCommand(strSQL, mCnn);
                int UpdateCount = cmd.ExecuteNonQuery();
                if (UpdateCount <= 0)
                {
                    MessageBox.Show("更新失败!");
                }
                else
                {
                    MessageBox.Show("更新成功!");
                }
      

  5.   

     if (UpdateCount <= 0) //没有这条记录,所以更新失败
                {
                    MessageBox.Show("更新失败!");
                }
                else   //
                {
                    MessageBox.Show("更新成功!");
                }