rfazendeiro Posted September 12, 2005 Posted September 12, 2005 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 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 Quote
Machaira Posted September 13, 2005 Posted September 13, 2005 You can do a switch on the NativeError or SQLState property of the Exception object in your catch block. To my knowledge you can't do a catch on a specific type of error for an Exception type. Quote Here's what I'm up to.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.