What is causing my OLEDbException, IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

家住魔仙堡 提交于 2019-11-27 23:47:47
Keith Sirmons

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

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.

BTW:

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 reserved words and symbols

Keith

..and have wrapped all column names in brackets anyway to rule it out.

Not only columns names that should be surrounded by square brackets Table names should as well For example, replace the below line

SELECT id FROM table1 WHERE id = 5

With the below line

SELECT [id] FROM [table1] WHERE [id] = 5

Another possible cause of this exception is if the File your trying to load/read does not exist.

I have found it useful to perform a "File.Exists" before trying to open the file just to make sure my code detects this specific cause of the "IErrorInfo.GetDescription failed with E_FAIL" exception correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!