OleDbException.ErrorCode lookup

W

WebSnozz

The OleDbException.ErrorCode is supposed to be an HRESULT. What scope
of errors this HRESULT maps to. I tried:

catch (OleDbException ex)
{
string test = ex.Errors[ex.ErrorCode].Message;
}

However, ErrorCode is a negative int and the indexer expects an
unsigned int, and HRESULTS shouldn't be negative(using the Convert
namespace for ToUint32 gives me an exception on trying to convert
errorcode). I am getting an error which indicate an object not found,
and the named object is a table name referred to in a query. So I'm
thinking that this error code applies to all cases where a table does
not exist, or it might be broader and apply to other types of failures.
In order to make my error message specialized for the error code, I'd
like to identify what scenarios it may apply to.

My hope was the Errors[errorCode].Message would give me a better idea
of the scope of the ErrorCode.

So what do I need to do to find out what scenarios would produce this
ErrorCode.

If I craft an informative error message to display to the user, right
now it would read as "Table " + tablename + " does not exist in the
database." but if I do this based on errorCode, then I'm afraid the
errorCode may be produced in other situations where the error message
is not necessarily true.

So what would be a good process for manually looking up these error
codes? I have the Error lookup utility from VS6 but it doesn't like
the negative int values.

This particular one is -2147217865 but I would really like to have a
process for doing this in the future. I haven't worked much with
HRESULTS in previous languages either, so take it easy on me if I sound
ignorant.

Thank in advance.
 
A

AaronLShumaker

I am able to paste this negative value into Calculator, switch to Hex,
switch to dword, and then did a search through win32 sdk header files
and found the oledberr.h file.

But now I can't figure out how to programmatically check for that
particular error code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top