这个代码哪里错了,可我觉得没有错啊 请各位高手帮帮忙
protected void Page_Load(object sender, EventArgs e)
{
string username = this.Login1.UserName = Request.Form["UserName"];
string userpwd = this.Request.Form["Password"];
OleDbConnection con = DB.createCon();
con.Open();
OleDbCommand cmd = new OleDbCommand("select username from user where username= '"+username+"' ", con);
int count= Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Response.Redirect("main.aspx");
}
}
执行后:
FROM 子句语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: FROM 子句语法错误。
源错误:
行 21: con.Open();
行 22: OleDbCommand cmd = new OleDbCommand("select username from user where username= '"+username+"' ", con);
行 23: int count= Convert.ToInt32(cmd.ExecuteScalar());
行 24: if (count > 0)
行 25: