简体   繁体   English

查询时出错

[英]Getting Error while Querying

I'm querying an access table called AC_ECONOMIC using VS 2012 C# WinForms Application. 我正在使用VS 2012 C#WinForms应用程序查询名为AC_ECONOMIC的访问表。 Here's my code, 这是我的代码,

con6 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath);
//string propQuery = String.Format("SELECT PROPNUM FROM [AC_ECONOMIC]");// WHERE SECTION = 4 AND QUALIFIER = CGA0112");

ad6.SelectCommand = new OleDbCommand("SELECT DISTINCT PROPNUM FROM [AC_ECONOMIC] WHERE SECTION = 4 AND QUALIFIER = '" + qual0 + "'", con6);

ds6.Clear();
con6.Open();
ad6.SelectCommand.ExecuteNonQuery(); //ERROR HERE
ad6.Fill(ds6);
con6.Close(); 

I keep getting the error, 我不断收到错误消息,

"IErrorInfo.GetDescription failed with E_FAIL(0x80004005)." “ IErrorInfo.GetDescription失败,出现E_FAIL(0x80004005)。

If I take the SECTION = 4 AND out of the query it doesn't give me there error but that's not the spefic data I'd like to get. 如果我从查询中取SECTION = 4 AND,它不会给我错误,但这不是我想要获取的特殊数据。 Can any tell me why I'm getting this error? 有谁能告诉我为什么我会收到此错误? Any help would be great. 任何帮助都会很棒。

SECTION is a reserved access keyword, try to include it into square brackets or backticks: SECTION是保留的访问关键字,请尝试将其包含在方括号或反引号中:

WHERE [SECTION] = 4

or

WHERE `SECTION` = 4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM