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

11

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 

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" 

then I get the exception.

The exception details are as follows:

  • Message: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
  • ErrorCode: -2147467259
  • NativeError: -533136361
  • SQLState: 3000
exception
ms-access
oledbconnection
asked on Stack Overflow Mar 20, 2013 by Keith Sirmons • edited Oct 17, 2017 by Arun Vinoth

3 Answers

13

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

answered on Stack Overflow Mar 25, 2013 by Keith Sirmons • edited Dec 31, 2015 by Shimmy Weitzhandler
8

..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
answered on Stack Overflow Dec 31, 2015 by Gouda • edited Feb 18, 2016 by Gouda
2

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.

answered on Stack Overflow Sep 30, 2013 by Chris Pietschmann

User contributions licensed under CC BY-SA 3.0