从VB转道而来验证密码出错
TextBox1,2分别为用户名,密码,运行下面的代码总是提示少个 "; "
请高手给出完整代码,立马给分。
protected void Button1_Click(object sender, EventArgs e)
{
string muser = Convert.ToString(Request.Form[ "TextBox1 "]);
string mpass = Convert.ToString(Request.Form[ "TextBox2 "]);
OleDbConnection myConn = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Server.MapPath( "~/App_Data/xx.mdb "));
String strSQL= "SELECT * FROM [表名] WHERE admin_user= ' "+muser+ " ' and admin_pass= ' "+mpass+ " ' ";
OleDbDataAdapter objCmd = New OleDbDataAdapter(strSQL,myConn);
DataSet ds = New DataSet();
objCmd.Fill(ds, "表名 ");
If (DS.Tables( "表名 ").Rows.Count=0);
Response.Write( "登录错误! ");
Else
{
Response.Write( "登录成功! ");
Session( "admin_user ")=muser;
Response.Redirect( "admin.aspx ");
}
}
------解决方案--------------------If (DS.Tables( "表名 ").Rows.Count=0)
{
Response.Write( "登录错误! ");
}
------解决方案--------------------老大 是小写的ds不是大写 是ds.Tables[ "表名 "].Rows.Count 不是() 还有你的if不加{}没关系 但你加个;是什么意思???
------解决方案--------------------if (ds.Tables[ "表名 "].Rows.Count == 0);
Response.Write( "登录错误! ");
Else
{
Response.Write( "登录成功! ");
Session[ "admin_user "]=muser;
Response.Redirect( "admin.aspx ");
}
------解决方案--------------------那
if ()
{
...
}
else
{
....
}
用小写。。建议楼主基础需要加强。