是什么导致我的OLEDbException IErrorInfo.GetDescription失败,出现E_FAIL(0x80004005) [英] What is causing my OLEDbException, IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

查看:136
本文介绍了是什么导致我的OLEDbException IErrorInfo.GetDescription失败,出现E_FAIL(0x80004005)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对Access数据库使用OleDbConnection,OldDbCommand和OleDbReader.

I am using an OleDbConnection, OldDbCommand, and OleDbReader against an Access database.

我在代码中调用的数据库中有一个命名查询.

I have a named query in the database which I am calling from the code.

从访问权限中运行查询时,该查询可以正常工作.

The query works correctly when it is ran from access.

多个资源指示该错误可能是由于在查询中使用保留字并将其用方括号引起的.我没有使用任何保留字,而是将所有列名都用括号括起来以排除它.

Several resources indicate the error could be caused by using reserved words in the query and to wrap them with brackets. I am not using any reserved words and have wrapped all column names in brackets anyway to rule it out.

试图确定问题出在哪里,我已将查询简化为一个简单的

Trying to determine where the problem is, I have simplified the query to a simple

SELECT id FROM table1 WHERE id = 5 

Ole连接不会引发异常.

which the Ole connection does not throw an exception.

当我介绍查询的下一部分时:

When I introduce the next portion of the query:

SELECT table1.id FROM table1 INNER JOIN storedQuery ON table1.id = storedQuery.id WHERE table1.id = 5" 

然后我得到了例外.

异常详细信息如下:

  • 消息:IErrorInfo.GetDescription失败,错误代码为E_FAIL(0x80004005).
  • 错误代码:-2147467259
  • NativeError:-533136361
  • SQLState:3000
  • Message: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
  • ErrorCode: -2147467259
  • NativeError: -533136361
  • SQLState: 3000

推荐答案

当我说查询不包含任何保留字时,我显然被弄错了.

I apparently was mistaken when I said the query did not contain any reserved words.

我正在使用的查询是从Access数据库中的另一个查询中选择的.另一个查询有一个导致问题的保留关键字.

The query I was using was selecting from another query in the Access Database. That other query had a reserved keyword that was causing the problem.

顺便说一句:

Access数据库引擎以不同的模式运行,具体取决于是从Access,数据访问对象,Access数据库引擎的Microsoft OLE Provider还是Microsoft Access ODBC驱动程序中调用它.它可以在ANSI模式或非ANSI(传统)模式下运行.

The Access database engine runs in different modes, depending on whether it is called from Access, data access objects, the Microsoft OLE Provider for the Access database engine, or the Microsoft Access ODBC driver. It can be run in either ANSI mode or non-ANSI (traditional) mode.

由于使用这两种模式会导致两组保留字稍有不同,因此使用保留字的查询可能在一种模式下工作而在另一种模式下失败

Because using these two modes results in two slightly different sets of reserved words, a query that uses a reserved word might work in one mode and fail in another mode

Access 2007保留字和符号

基思

这篇关于是什么导致我的OLEDbException IErrorInfo.GetDescription失败,出现E_FAIL(0x80004005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆