111,120
社区成员
发帖
与我相关
我的任务
分享 public bool UserCheck()
{
bool flag = false;
string connction = "Data Source=.;Initial Catalog=MySchool;User ID=sa;pwd=123456";
SqlConnection coon = new SqlConnection(connction);
try
{
coon.Open();
string sql = string.Format("select count(*) from Admin where LoginId='{0}' and LoginPwd='{1}'", TxtName.Text.Trim(), TxtPwd.Text.Trim());
SqlCommand cmd = new SqlCommand(sql, coon);
int result = (int)cmd.ExecuteScalar();
if (result > 0)
{
flag= true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
coon.Close();
}
return flag;
}