【发布时间】: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