Does anyone know how to extract the SqlServer error code when an
SqlException occurs?

If I excute a stored procedure via the SqlCommand class and an exception
occurs (say a table is locked), how do I get the SqlServer 2000 error code?
It seems that the SqlException contains one or more SqlError objects but
neither of these objects contains the error code. Or did I miss it?

I know that there is a message in the SqlError and various other properties
like the error level etc, but I don't think these are specific enough for me
to identify a particular error. The message is probably unique but I don't
want to start comparing strings because this is not reliable.

Gary Leighton


KSS Ltd
A division of Knowledge Support Systems Group plc
Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS  England
Company Registration Number 2800886 (Limited) 3449594 (plc)
Tel: +44 (0) 161 228 0040       Fax: +44 (0) 161 236 6305
mailto:[EMAIL PROTECTED]            http://www.kssg.com


The information in this Internet email is confidential and may be legally privileged. 
It is intended solely for the addressee(s). Access to this Internet email by anyone 
else is unauthorised.

If you are not the intended recipient, any disclosure, copying, distribution or any 
action taken or omitted to be taken in reliance on it, is prohibited and may be 
unlawful. When addressed to our clients any opinions or advice contained in this 
Internet email are subject to the terms and conditions expressed in the governing 
engagement letter or contract.

This email message and any attached files have been scanned for the presence of 
computer viruses.  However you are advised that you open any attachments at your own 
risk.


You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to