在关键字‘user’附近有语法错误
stringmySql=ConfigurationManager.ConnectionStrings["SQL"].ConnectionString;SqlConnect...
string mySql = ConfigurationManager.ConnectionStrings["SQL"].ConnectionString;
SqlConnection myCon = new SqlConnection(mySql);
string cmdtext = "SELECT username,userpwd FROM users WHERE(username='" + TextBox1.Text + "' and userpwd='" + TextBox2.Text + "')";
SqlCommand mycmd = new SqlCommand(cmdtext, myCon);
try
{
myCon.Open();
SqlDataReader mydr = mycmd.ExecuteReader();
while (mydr.Read())
{
Response.Redirect("user.aspx");
}
}
catch (SqlException sqlex)
{
Response.Write(sqlex.Message + "<br>");
}
finally
{
myCon.Close();
}
我编写了这样一段代码,总是说在关键字‘user’附近有语法错误,这是什么问题啊? 展开
SqlConnection myCon = new SqlConnection(mySql);
string cmdtext = "SELECT username,userpwd FROM users WHERE(username='" + TextBox1.Text + "' and userpwd='" + TextBox2.Text + "')";
SqlCommand mycmd = new SqlCommand(cmdtext, myCon);
try
{
myCon.Open();
SqlDataReader mydr = mycmd.ExecuteReader();
while (mydr.Read())
{
Response.Redirect("user.aspx");
}
}
catch (SqlException sqlex)
{
Response.Write(sqlex.Message + "<br>");
}
finally
{
myCon.Close();
}
我编写了这样一段代码,总是说在关键字‘user’附近有语法错误,这是什么问题啊? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询