private void button1_Click(object sender, EventArgs e)
        {
            if (!(this.textBox1.Text == this.textBox2.Text) || (this.textBox1.Text.Length == 0))
            {
                MessageBox.Show("两次密码的输入不一致!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string PswStrComd = "update T_Users set Password=" + "'" + this.textBox2.Text.ToString().Trim() + "'" + " where Username=" + "'" + denglufrm.Username + "'";
            SqlConnection PswConn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True
");
            SqlCommand PswComd = new SqlCommand(PswStrComd, PswConn);
            PswComd.Connection.Open();
            int Suc = PswComd.ExecuteNonQuery();
            if (Suc > 0)
            {
                MessageBox.Show("修改用户密码操作成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("修改用户密码操作失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

解决方案 »

  1.   

    int Suc = PswComd.ExecuteNonQuery();
    这个就是修改成功与否的标记啊???
    如果  MessageBox.Show("修改用户密码操作成功! 这个就说明成功了
    如果   MessageBox.Show("修改用户密码操作失败!", 这个就说明没有成功,有可能是你的 sql语句的问题...自己打个断点查查看..
      

  2.   

     "update T_Users set Password='" + this.textBox2.Text.Trim() + "' where Username='" + denglufrm.Username + "'";
      

  3.   

    你的SQL更新语句那么多的‘ 看的头都晕啊 干嘛不用string.format呢