private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=.;database=Systems;uid=sa;pwd=123456");
conn.Open();
SqlCommand cmd = new SqlCommand("select ID,password from Users where ID='" + textBox1.Text + "'and password= '" + textBox2.Text + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
if (sdr.HasRows)
{
sdr.Close();
if (textBox3.Text == textBox4.Text)
{
// SqlCommand cld = new SqlCommand("UPDATE Users SET password='" + textBox3.Text + "'where ID='" + textBox1.Text + "'", conn);
string Str = "UPDATE Users SET password='" + textBox3.Text + "'where ID='" + textBox1.Text + "'";
cmd = new SqlCommand(Str, conn);
int result = cmd.ExecuteNonQuery();
if (result>0)
{
MessageBox.Show("密码修改成功");
Form2 form2 = new Form2();
form2.Show();
this.Close();
}
else
{
MessageBox.Show("密码修改失败!");
}
}
else
{
MessageBox.Show("两次密码输入不一致!");
}
}
conn.Close();
}
}
密码每次都修改成功了,可是每次修改成功他都弹出密码修改失败的提示是怎么回事啊???
{
SqlConnection conn = new SqlConnection("server=.;database=Systems;uid=sa;pwd=123456");
conn.Open();
SqlCommand cmd = new SqlCommand("select ID,password from Users where ID='" + textBox1.Text + "'and password= '" + textBox2.Text + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
if (sdr.HasRows)
{
sdr.Close();
if (textBox3.Text == textBox4.Text)
{
// SqlCommand cld = new SqlCommand("UPDATE Users SET password='" + textBox3.Text + "'where ID='" + textBox1.Text + "'", conn);
string Str = "UPDATE Users SET password='" + textBox3.Text + "'where ID='" + textBox1.Text + "'";
cmd = new SqlCommand(Str, conn);
int result = cmd.ExecuteNonQuery();
if (result>0)
{
MessageBox.Show("密码修改成功");
Form2 form2 = new Form2();
form2.Show();
this.Close();
}
else
{
MessageBox.Show("密码修改失败!");
}
}
else
{
MessageBox.Show("两次密码输入不一致!");
}
}
conn.Close();
}
}
密码每次都修改成功了,可是每次修改成功他都弹出密码修改失败的提示是怎么回事啊???