![](/img/trans.png)
[英]multiple Parameters - Syntax error in string in query expression: VS 2010 with MS-Access 2003
[英]MS-Access Query Syntax
我有mysql的背景。 现在,我正在使用C#进行MS-Access。 我试过以下SQL查询,但会引发异常
查询1:
String strSql = "Select * from Employees orderby EmployeeID desc limit 1;";
OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, conn);
adapter.Fill(dt);
String strSql = "Select * from Employees orderby EmployeeID asc limit 1;";
OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, conn);
adapter.Fill(dt);
常见例外1:
Additional information: Syntax error in FROM clause.
查询2:
String strSql = "select * from Employees where EmployeeID = (select min(EmployeeID) from Employees where EmployeeID < '" + Int64.Parse(this.txtBoxID.Text) + "');";
OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, conn);
adapter.Fill(dt);
String strSql = "select * from Employees where EmployeeID = (select min(EmployeeID) from Employees where EmployeeID > '" + Int64.Parse(this.txtBoxID.Text) + "');";
OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, conn);
adapter.Fill(dt);
常见例外2:
Additional information: Data type mismatch in criteria expression.
我的数据库在下面
为什么不使用查询设计器在访问中创建查询,更改为sql视图,然后将sql复制回代码中?
此外,我认为您必须具有访问权限,
SELECT TOP 1 * from Employees;
而不是
Select * from Employees limit 1;
并查询1:
Select * from Employees order by EmployeeID ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.