C#为何修改后,不能更新到数据库?
Class1db=newClass1();stringsqlText="updateuserssetpassword=@passwhereusername=@name";...
Class1 db = new Class1();
string sqlText = "update users set password=@pass where username=@name";
string sqlText1 = "select * from users where password =@password ";
SqlParameter pUserid = new SqlParameter("@password ", textBox3.Text.Trim());
DataSet data = db.DBselct(sqlText1, pUserid);
SqlParameter xsbh = new SqlParameter("@pass", textBox1.Text.Trim());
SqlParameter xsnl = new SqlParameter("@name", textBox2.Text.Trim());
string newPwd1 = this.textBox1.Text;
string newPwd2 = this.textBox2.Text;
if (this.textBox1.Text != string.Empty && this.textBox2.Text != string.Empty && this.textBox3.Text != string.Empty)
{
if (data.Tables[0].Rows.Count == 0)
{
MessageBox.Show("原密码错误", "");
}
else
{
if (newPwd1.Equals(newPwd2))
{
db.DBinsert(sqlText, xsbh, xsnl);
MessageBox.Show("修改成功", "");
}
else
{
MessageBox.Show("两次输入的新密码不相同,请重新输入!", "");
}
}
}
else
MessageBox.Show("密码不能为空!", "");
button2_Click(null, null);
} 展开
string sqlText = "update users set password=@pass where username=@name";
string sqlText1 = "select * from users where password =@password ";
SqlParameter pUserid = new SqlParameter("@password ", textBox3.Text.Trim());
DataSet data = db.DBselct(sqlText1, pUserid);
SqlParameter xsbh = new SqlParameter("@pass", textBox1.Text.Trim());
SqlParameter xsnl = new SqlParameter("@name", textBox2.Text.Trim());
string newPwd1 = this.textBox1.Text;
string newPwd2 = this.textBox2.Text;
if (this.textBox1.Text != string.Empty && this.textBox2.Text != string.Empty && this.textBox3.Text != string.Empty)
{
if (data.Tables[0].Rows.Count == 0)
{
MessageBox.Show("原密码错误", "");
}
else
{
if (newPwd1.Equals(newPwd2))
{
db.DBinsert(sqlText, xsbh, xsnl);
MessageBox.Show("修改成功", "");
}
else
{
MessageBox.Show("两次输入的新密码不相同,请重新输入!", "");
}
}
}
else
MessageBox.Show("密码不能为空!", "");
button2_Click(null, null);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询