[英]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.