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

4

15

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
Heinous answered 20/3, 2013 at 20:41 Comment(0)
H
14

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

Heinous answered 25/3, 2013 at 13:50 Comment(2)
Out of curiosity, what was the reserved keyword in the query that failed?Ambiguity
Too many years ago to remember.. The important part for me was finding out that there are different reserve words depending on which way you are calling the stored queriesHeinous
D
9

..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
Derby answered 31/12, 2015 at 3:22 Comment(0)
C
8

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.

Carangid answered 30/9, 2013 at 14:3 Comment(4)
Lol, I spent hour on this error message, but I am glad now that it works, thx :-)Publea
God bless Chris.Cathedral
This was the cause for me. We had a separate process (where the timing wasn't right) that was moving the file before it had a chance to be read in as Excel (by the process that had originally saved the file there). In our case, there were no other lines of code between Saving the File and Reading in as Excel; but a separate process was sometimes picking them off right between those two states. I added a pause between checking for files, and then a small delay between reading the list of File Names and processing to move them out.Neutralism
Thank you! - after spending a couple of hours (that seemed like an eternity) chasing my tail this is what saved me. I had to install the access dB 32 bit driver side by side with the 64 bit driver and after having done that I was getting this error and assumed I must have a failed/corrupted install but it was simply a case of the file not being there, Bless you Chris!!!Damning
C
0

My problem was a reserved word in this instance Domain. With so many reserved words it is difficult to debug. My solution was in visual studio using the "Data Source" then building a query, it automatically detected the reserved word and put [] around it so it looked like Orders.[Domain]. You don't have to put brackets around your table.

Ceramics answered 1/12, 2022 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.