rfazendeiro
Centurion
- Joined
- Mar 8, 2004
- Messages
- 110
I'm working currently in an application with access and odbc.
I need to catch diferente errors that happen so i can treat them diferently. but it always returns the same exception. I want somthing like this
this is the simplified version of what want. But it returns always the same error and i cannot treat it.
this is when data source is not found
System.Data.ODBC.OdbcException:EROOR[IM002][...]Data source not found and no default driver specified.
this is when table is loked in design
System.Data.ODBC.OdbcException:Error[HY000][...]The table XXXX is already opened exclusively by another user, ....
how can is distinguish these exceptions from one another??
thx to all
I need to catch diferente errors that happen so i can treat them diferently. but it always returns the same exception. I want somthing like this
Code:
try
{
execute query to the database
}
catch (exception file not found)
{
rerturn -1
}
catch (exception odbc not found)
{
rerturn -2
}
catch (exception table locked)
{
rerturn -3
}
finally
{
close connections
}
this is the simplified version of what want. But it returns always the same error and i cannot treat it.
this is when data source is not found
System.Data.ODBC.OdbcException:EROOR[IM002][...]Data source not found and no default driver specified.
this is when table is loked in design
System.Data.ODBC.OdbcException:Error[HY000][...]The table XXXX is already opened exclusively by another user, ....
how can is distinguish these exceptions from one another??
thx to all