database name in SqlException?

  • Thread starter Thread starter bdgreen
  • Start date Start date
B

bdgreen

Hi,

I searched around in SqlException, but couldn't find the name of the
database in question after catching a SqlException. It isn't
SqlException.Server, which has the database *server* name. Anyone know
where I can find the database name?

Thanks in advance
 
Miha said:
Don't you know which database you are connected to?

I'm writing something to look at numerous SqlExceptions across a large
codebase, from different areas of code. So, the exceptions could be
happening on any number of different databases.
 
Hi,

Ah, ok, I see. I couldn't find database name, either.
As a workaround you could wrap all calls to database in try/catch block (I
guess you have to already) and in catch block create your SqlException
derived exception that will hold additional database property.
 
Miha said:
Hi,

Ah, ok, I see. I couldn't find database name, either.
As a workaround you could wrap all calls to database in try/catch block (I
guess you have to already) and in catch block create your SqlException
derived exception that will hold additional database property.

There's a wrapper with database name now, I just thought I'd check if
it's somewhere in SqlException, in case someone bypasses the wrapper.
But, if it isn't in there, it isn't in there ;) Thanks for checking,
and for the replies.
 
Back
Top