这个是判断的方法 主要是我在数据库中用1表示记住密码 2表示为记住密码
调用在load事件中
public void panmima()
{
string sql = "select mima from Users where Id ='"+int.Parse (this.cbo_haoma .Text )+"'"; 这是在users表中找到记住密码或者为记住的返回值
string sql1 = "";
int jimima = DBHeper.ExecuteScalar(sql);
if (jimima == 1)
{
this.checkBox1.Checked = true;
sql1 = " select LoginPwd from Users where Id ='" + int.Parse(this.cbo_haoma.Text) + "'";
SqlDataReader mima = DBHeper.ExecuteRead(sql1);
mima.Read();
string mi = (string)mima[0];
mima.Close();
DBHeper.connection.Close();
this.txtpwd.Text = mi;
}
else
{
this.checkBox1.Checked = false;
this.txtpwd.Text = "";
}
}
这个是判断 改数据裤中的数据
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1 .Checked ==true)
{
string sql = " update Users set mima =1";
int num;
num = DBHeper.ExecuteNonquery(sql);
if (num >0)
{
}
}
else
{
string sql = " update Users set mima =2";
int num;
num = DBHeper.ExecuteNonquery(sql);
if (num > 0)
{
}
}
}
希望能有点用哦…加油