using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.IO.Compression;
using System.IO;
using System.Text;
using System.Collections.Generic;public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
 protected void LoginButton_Click1(object sender, EventArgs e)
    {        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(".") + "..\\data\\name.mdb;");
        con.Open();
        string u = UserName.Text;
        string p = Password.Text;
        OleDbCommand d = new OleDbCommand("SELECT * FROM in where id='"+u+"' and pw='"+p+"'", con);
              int i = Convert.ToInt32(d.ExecuteNonQuery());
        if (i > 0)
        {
            Response.Redirect("index.aspx");
        }
        else
        {
            Response.Redirect("error.aspx");
        }    }
}
错误:: FROM 子句语法错误。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: FROM 子句语法错误。源错误: 
行 32:       
行 33: 
行 34:         int i = Convert.ToInt32(d.ExecuteNonQuery());
行 35:         if (i > 0)
行 36:         {
 源文件: c:\Documents and Settings\Administrator\桌面\sine\landing.aspx.cs    行: 34 堆栈跟踪: 
[OleDbException (0x80040e14): FROM 子句语法错误。]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +56
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +105
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +88
   _Default.LoginButton_Click1(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\桌面\sine\landing.aspx.cs:34
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921

解决方案 »

  1.   

    ("SELECT * FROM [in] where id='"+u+"' and pw='"+p+"'", con); in为关键字 加[]以区分
      

  2.   

    你的表名是叫in吗?
    如果是的话,加个中括号试试
    OleDbCommand d = new OleDbCommand("SELECT * FROM [in] where id='"+u+"' and pw='"+p+"'", con); 
      

  3.   

    SELECT * FROM in where id='"+u.Replace("'","")+"' and pw='"+p.Replace("'","")+"'
      

  4.   

    in 是sql 关键字 
    关键字作为表名时加中括号
     OleDbCommand d = new OleDbCommand("SELECT * FROM [in] where id='"+u+"' and pw='"+p+"'", con); 
      

  5.   

    建议写sql语句时 表名 字段名 都加上[]
      

  6.   

     OleDbCommand d = new OleDbCommand("SELECT * FROM [in] where id='"+u+"' and pw='"+p+"'", con); 
    正解
      

  7.   


    OleDbCommand d = new OleDbCommand("SELECT * FROM [in] where id='"+u+"' and pw='"+p+"'", con); 怎么还能用in做表名啊。
      

  8.   

    in为关键字不能用做表名,或这样写[in]
      

  9.   

    SELECT * FROM [in] where [id]='"+u+"' and pw='"+p+"'"  
    in是关键字,要加[]括起来
      

  10.   

    楼哥
    那有用in来取表名的?把in加上[]先。
      

  11.   

    in为关键字不能用做表名,或这样写[in]