C#中SQL查询出错 抛异常 求大神解决
这是点击事件代码privatevoidbtnLogin_Click(objectsender,RoutedEventArgse){DataTabletable=SqlHe...
这是点击事件代码
private void btnLogin_Click(object sender, RoutedEventArgs e) { DataTable table = SqlHelper.ExecuteDataTable("select * from T_User where UserName=@UserName",new SqlParameter("@UserName", txtUserName.Text) ); if(table.Rows.Count<=0) { MessageBox.Show("用户名不存在"); return; } if(table.Rows.Count>1) { MessageBox.Show("用户名重复了"); return; } DataRow row = table.Rows[0]; string dbPassword = (string)row["UserPassword"]; if(dbPassword!=pwdPassword.Password) { MessageBox.Show("密码错误"); return; } else { MessageBox.Show("登陆成功"); } }
这是SqlHelper代码 展开
private void btnLogin_Click(object sender, RoutedEventArgs e) { DataTable table = SqlHelper.ExecuteDataTable("select * from T_User where UserName=@UserName",new SqlParameter("@UserName", txtUserName.Text) ); if(table.Rows.Count<=0) { MessageBox.Show("用户名不存在"); return; } if(table.Rows.Count>1) { MessageBox.Show("用户名重复了"); return; } DataRow row = table.Rows[0]; string dbPassword = (string)row["UserPassword"]; if(dbPassword!=pwdPassword.Password) { MessageBox.Show("密码错误"); return; } else { MessageBox.Show("登陆成功"); } }
这是SqlHelper代码 展开
2个回答
2014-12-28
展开全部
1720406057 远程调试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询