真是活见鬼了,大家都来看看吧,白送分的题啊
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox2.Text == string.Empty || TextBox3.Text == string.Empty)
{
TextBox1.Text = "请输入用户名和密码";
return;
}
else
{
SqlConnection conn1 = new SqlConnection("server=.;Database=test1;pwd=123;uid=sa;");
conn1.Open();
string comstr = "select Id from User";
SqlCommand com = new SqlCommand(comstr, conn1);
string uname;
string pword;
int i = 0;
SqlDataReader sdr = com.ExecuteReader();
if (sdr.Read())
{
uname = com.ExecuteReader().GetString(0);
pword = com.ExecuteReader().GetString(1);
if (TextBox2.Text == uname && TextBox3.Text == pword)
{
TextBox1.Text = "登录成功";
i = 1;
return;
}
if (i == 0)
{
TextBox1.Text = "登录失败";
}
}
}
}
错误提示:
![]()
{
if (TextBox2.Text == string.Empty || TextBox3.Text == string.Empty)
{
TextBox1.Text = "请输入用户名和密码";
return;
}
else
{
SqlConnection conn1 = new SqlConnection("server=.;Database=test1;pwd=123;uid=sa;");
conn1.Open();
string comstr = "select Id from User";
SqlCommand com = new SqlCommand(comstr, conn1);
string uname;
string pword;
int i = 0;
SqlDataReader sdr = com.ExecuteReader();
if (sdr.Read())
{
uname = com.ExecuteReader().GetString(0);
pword = com.ExecuteReader().GetString(1);
if (TextBox2.Text == uname && TextBox3.Text == pword)
{
TextBox1.Text = "登录成功";
i = 1;
return;
}
if (i == 0)
{
TextBox1.Text = "登录失败";
}
}
}
}
错误提示:
...全文


