关于用户登陆的问题
string User = this.TextBoxUser.Text.ToString();string Pwd = this.TextBoxPwd.Text.ToString();
if (User == "" | Pwd == "")
{
this.Label3.Visible = true;
this.Label3.Text = "请输入用户名或密码";
}
else
{
SqlConnection myconn = new SqlConnection("Data Source=34-d248b3d2c78d;Initial Catalog=MMIS;User ID=sa;Password=4370532");
myconn.Open();
string mysql = "select * from memberInfo where 帐号= " + " ' " +User + " '" + "and 密码="+ "'" + Pwd + " ' ";//这句没错
// Response.Write(mysql);
// Response.End();
SqlCommand mycmd = new SqlCommand(mysql, myconn);
SqlDataReader mydr = mycmd.ExecuteReader();
try
{
if (mydr.Read())
{
Label3.Visible = true;
Label3.Text = "登录成功";
}
else
{
Label3.Visible = true;
Label3.Text = "用户名或密码错误";
}
}
finally
{
mydr.Close();
myconn.Close();
}
}
为什么我输入正确的用户名和密码,但还是输出"用户名或密码错误"??? 为什么急呀
}
protected void Button3_Click(object sender, EventArgs e)
{
this.TextBoxUser.Text = "";
this.TextBoxPwd.Text = "";
}
}