The error I'm currently looking at (timeout due to table lock) gives 0 as the SqlError.State.
So it doesn't look like the answer, at least not for this type of error. -----Original Message----- From: Edward Ferron [mailto:[EMAIL PROTECTED]] Sent: 30 January 2003 14:27 To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Extracting SqlServer error codes using SqlC ommands I think you are looking for the SqlError.State property. Is that not the Sql server error code? HTH Ed -----Original Message----- From: Gary Leighton To: [EMAIL PROTECTED] Sent: 1/30/03 6:19 AM Subject: [ADVANCED-DOTNET] Extracting SqlServer error codes using SqlCommands 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. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.