C#修改密码代码
if (textBox1.Text == ""||textBox2.Text == ""||textBox3.Text == "") { if (MessageBox.Show(" 您输入的信息不完整! ,是否关闭窗口", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Close(); } } else if(textBox2.Text!=textBox3.Text) { if (MessageBox.Show(" 您的新密码输入错误! ,是否关闭窗口", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Close(); } } else if (textBox1.Text != "") { string constr = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=anne"; SqlConnection sqlConnection1 = new SqlConnection(constr); string sq1 = "select 密码 from 密码表 where 用户名='admin'"; SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(sq1, sqlConnection1); DataSet dt1 = new DataSet(); sqlDataAdapter1.Fill(dt1, "密码表"); string sq2= textBox1.Text; string sq3 = (string)dt1.Tables["密码表"].Rows[0]["密码"]; if (sq2.Equals(sq3.Trim()) && textBox2.Text == textBox3.Text) { string constr1 = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=anne"; string sq4 = "update 密码表 set 密码='" + textBox2.Text + "' where 密码='" + textBox1.Text + "'"; SqlConnection sqlConnection = new SqlConnection(constr1); sqlConnection.Open(); SqlCommand cd = new SqlCommand(sq4, sqlConnection); SqlDataReader sr = cd.ExecuteReader(); MessageBox.Show(" 密码已修改成功 ", "提 醒");