本来老是提示SQL语句那里有错的,后来改了一下就不会了,但是却老是提示SqlDataReader dr = mycom.ExecuteReader();
这一句有错
String myco = ConfigurationSettings.AppSettings["mc"];
SqlConnection mycon = new SqlConnection(myco);
string str = "select * from users where id= '" + TextBox1.Text.Trim() + "' and '" + TextBox2.Text.Trim() + "'";
SqlCommand mycom = new SqlCommand(str, mycon);
mycon.Open();
SqlDataReader dr = mycom.ExecuteReader();
if (dr.Read())
{
Session["id"] = TextBox1.Text;
TextBox1.Text = "欢迎您";
mycon.Close();
}
else
{
Response.Write("<script language='javascript'>alert('用户名或密码不正确,请重新输入!');</script>");
TextBox1.Text = "";
TextBox2.Text = "";
请教各位了!
这一句有错
String myco = ConfigurationSettings.AppSettings["mc"];
SqlConnection mycon = new SqlConnection(myco);
string str = "select * from users where id= '" + TextBox1.Text.Trim() + "' and '" + TextBox2.Text.Trim() + "'";
SqlCommand mycom = new SqlCommand(str, mycon);
mycon.Open();
SqlDataReader dr = mycom.ExecuteReader();
if (dr.Read())
{
Session["id"] = TextBox1.Text;
TextBox1.Text = "欢迎您";
mycon.Close();
}
else
{
Response.Write("<script language='javascript'>alert('用户名或密码不正确,请重新输入!');</script>");
TextBox1.Text = "";
TextBox2.Text = "";
请教各位了!
string str = "select * from users where id= '" + TextBox1.Text.Trim() + "' and '" + TextBox2.Text.Trim() + "'"; SQL语句的where语句有问题..........