How to distinguish a "communications failure" exception from a "sql syntax" (and the like) exception

O

Olivier R

Hello,
I'm trying to distinguish two kinds of OdbcException in my code
because I want to know if the OdbcException is caused by a
"communications failure" in order to close the connection.

As far as I remember, I was able to do that when I was working
with JAVA JDBC. Indeed, in JDBC, there was a SQLException class to handle
"sql syntax" and the like exceptions.


I also want the solution to be database independant.
So the code must work through ODBC.NET with different databases.
I also don't want the solution to identify the SQLSTATE
in the error because the SQLSTATE depends on the ODBC version of the
driver.


Thanks.
Olivier.
 
M

Miha Markic

Hi,

I think that odbc errors are provider related, thus you'll have to check the
exception properties itself - they will depend on provider (you might also
iterate through Errors property) .
 

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