作业帮 > 综合 > 作业

string sql = "select * from user where user_name='" +t1.Text

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/30 22:34:33
string sql = "select * from user where user_name='" +t1.Text.Trim()+ "' and user_password='"+t2.Tex
string sql = "select * from user where user_name='" +t1.Text.Trim()+ "' and user_password='"+t2.Text.Trim()+ "'";错在哪里啊?
protected void Button1_Click(object sender,EventArgs e)
{
string str="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server .MapPath ("App_Data/user.mdb");
OleDbConnection conn = new OleDbConnection(str);
conn.Open();
string sql = "select * from user where user_name='" +t1.Text.Trim()+ "' and user_password='"+t2.Text.Trim()+ "'";
OleDbCommand oledbcommand = new OleDbCommand(sql,conn);
OleDbDataReader rd = oledbcommand.ExecuteReader();
int add=0;
while (rd.Read()) { add++; }
if(add ==0){
Response .Write ("需要进入系统!");}
else
{ Response .Redirect ("index.aspx");
}
请帮小弟看看这段asp.net中的代码,我点登录按钮时总是提示“from子句错误”,
string sql = "select * from [user] where [user_name]='" +t1.Text.Trim()+ "' and [user_password]='"+t2.Text.Trim()+ "'";