2023年6月21日发(作者:)

qtsqlbase参数化访问数据库SqlCommandcmd=Comm。。。using System; using c; using entModel; using ; using g; ; using ; using ; using uration; using ent; namespace 复习登录 { public partial class login : Form { public login() { InitializeComponent(); } string str =tionStrings["sqlserver2008"].ConnectionString; DateTime dt1; private void btn_login_Click(object sender,EventArgs e) { using(SqlConnection cnn=new SqlConnection(str)) { using (SqlCommand cmd=Command()) {dText = "select * from T_User where username=@username"; hValue("@username",txt_); (); using (SqlDataReader reader = eReader()) { if (()) { int Error =32(reader["Error"].ToString()); if (Error >= 3) { string sqltime = reader["Errortime"].ToString(); dt1 = (sqltime);DateTime dt2 = ; TimeSpan ts = dt2 - dt1; if (inutes < 5) { ("对不起,你已经输⼊3次连续错误密码,系统已经将账户冻结,请在五分钟后再试"); return; } else { clearerror(); } } string sqlpassword = reader["Password"].ToString(); if(sqlpassword == txt_) { clearerror(); if (txt_r() == "ADMIN") { (); main m = new main();(); } else { ("登录成功"); } } else { ("密码错误"); adderror(); } } else { ("⽤户名不存在"); } } } } } private void adderror() { dt1 = ; using (SqlConnection cnn=new SqlConnection(str)) { using (SqlCommandcmd=Command()) { (); dText = "update T_User set Error=Error+1,Errortime=@Errortime whereusername=@username"; hValue("@Errortime", dt1); hValue("@username",txt_); eNonQuery(); } } } private void clearerror() { using (SqlConnection cnn=new SqlConnection(str)) { using(SqlCommand cmd=Command()) { (); dText = "update T_User set Error=0 whereusername=@username"; (new SqlParameter("username", txt_)); eNonQuery(); } } } } }

2023年6月21日发(作者:)

qtsqlbase参数化访问数据库SqlCommandcmd=Comm。。。using System; using c; using entModel; using ; using g; ; using ; using ; using uration; using ent; namespace 复习登录 { public partial class login : Form { public login() { InitializeComponent(); } string str =tionStrings["sqlserver2008"].ConnectionString; DateTime dt1; private void btn_login_Click(object sender,EventArgs e) { using(SqlConnection cnn=new SqlConnection(str)) { using (SqlCommand cmd=Command()) {dText = "select * from T_User where username=@username"; hValue("@username",txt_); (); using (SqlDataReader reader = eReader()) { if (()) { int Error =32(reader["Error"].ToString()); if (Error >= 3) { string sqltime = reader["Errortime"].ToString(); dt1 = (sqltime);DateTime dt2 = ; TimeSpan ts = dt2 - dt1; if (inutes < 5) { ("对不起,你已经输⼊3次连续错误密码,系统已经将账户冻结,请在五分钟后再试"); return; } else { clearerror(); } } string sqlpassword = reader["Password"].ToString(); if(sqlpassword == txt_) { clearerror(); if (txt_r() == "ADMIN") { (); main m = new main();(); } else { ("登录成功"); } } else { ("密码错误"); adderror(); } } else { ("⽤户名不存在"); } } } } } private void adderror() { dt1 = ; using (SqlConnection cnn=new SqlConnection(str)) { using (SqlCommandcmd=Command()) { (); dText = "update T_User set Error=Error+1,Errortime=@Errortime whereusername=@username"; hValue("@Errortime", dt1); hValue("@username",txt_); eNonQuery(); } } } private void clearerror() { using (SqlConnection cnn=new SqlConnection(str)) { using(SqlCommand cmd=Command()) { (); dText = "update T_User set Error=0 whereusername=@username"; (new SqlParameter("username", txt_)); eNonQuery(); } } } } }