【问题标题】:Syntax error in FROM clause AccessFROM 子句访问中的语法错误
【发布时间】:2015-01-31 18:44:38
【问题描述】:

我想从 Access 数据库中读取数据以检查密码是否正确。我使用此代码:

var check=false;
OleDbCommand c = new OleDbCommand();
c.Connection = co //the connection to the Database;
c.CommandText = "select * FROM User Where user_name='"+usee+"'"; 
OleDbDataReader re = c.ExecuteReader();
while (re.Read())
{
    if (re.ToString() == pasy)
    {
        check = true;
    }
}

它给了我一个“FROM 子句中的语法错误”。当代码执行时。

【问题讨论】:

  • User 是 Access 中的保留字。我认为您可以使用反引号来允许它,但建议将该表名更改为 Users 或其他名称
  • 非常感谢它的工作

标签: database c#-2.0 accessdatasource


【解决方案1】:

“用户”是 Access 的保留字。

这里是保留字列表: http://support.microsoft.com/kb/286335/en-us

这是描述该问题的页面: http://support.microsoft.com/kb/181489/en-us

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-08
    • 1970-01-01
    • 2013-11-02
    • 2019-04-20
    相关资源
    最近更新 更多