errorTime = errorTime - 1; string username = txtName.Text.Trim(); //ååºè´¦å·
string pw = txtPwd.Text.Trim(); //ååºå¯ç
string constr = "Server=.;DataBase=SU; Integrated Security=True"; //设置è¿æ¥å符串
SqlConnection mycon = new SqlConnection(constr); //å®ä¾åè¿æ¥å¯¹è±¡
mycon.Open();
SqlCommand mycom = mycon.CreateCommand(); //å建SQLå½ä»¤æ§è¡å¯¹è±¡
string s1 = "select account,password from register where account='" + username + "' and password='" + pw + "'"; //ç¼åSQLå½ä»¤
mycom.CommandText = s1; //æ§è¡SQLå½ä»¤
SqlDataAdapter myDA = new SqlDataAdapter(); //å®ä¾åæ°æ®éé
å¨
myDA.SelectCommand = mycom; //让éé
å¨æ§è¡SELECTå½ä»¤
DataSet myDS = new DataSet(); //å®ä¾åç»ææ°æ®é
int n = myDA.Fill(myDS, "register"); //å°ç»ææ¾å
¥æ°æ®éé
å¨ï¼è¿åå
ç¥ä¸ªæ°
if (n != 0) {
if (checkCode.Text == textCheck.Text) {
MessageBox.Show("欢è¿ä½¿ç¨ï¼"); //ç»å½æå
this.Close();
} else {
MessageBox.Show("éªè¯ç å¡«åé误");
textCheck.Text = "";
}
} else
if (errorTime < 3) {
MessageBox.Show("ç¨æ·åæå¯ç æéã请éæ°è¾å
¥ï¼è¿æ" + errorTime.ToString() + "次æºä¼");
txtName.Text = ""; //æ¸
空账å·
txtPwd.Text = ""; //æ¸
空å¯ç ?
txtName.Focus(); //å
æ 设置å¨è´¦å·ä¸
} else {
MessageBox.Show("ä½ è¾å
¥çç¨æ·åæå¯ç 已达ä¸æ¬¡? å°éåºç¨åº");
this.Close();
}
温馨提示:答案为网友推荐,仅供参考