Detection of failing to connect to database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, in my catch(SqlException se) block, how can I tell from the value of SqlException members (e.g. number, state etc) that the exception is due to fail to connecting to database? there are a block of codes inside my try{ }, including define SqlCommand, assign values to SqlParameter, open connection and execute SqlCommand etc. I don't want to add 1 more try-catch on my SqlConnection.Open() statement. Thanks a lot in advance
 
Hi, in my catch(SqlException se) block, how can I tell from the value of
SqlException members (e.g. number,

you can use the number property of SqlException.

regards,
Wiktor
 
Back
Top