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

  • Thread starter Thread starter Olivier R
  • Start date Start date
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.
 
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) .
 
Back
Top