OK, from what I can gather, the SqlError.Number property and the
SqlException.Number property can both contain the same SqlServer error code.

But not always. It seems that these two fields can contain non-SqlServer
error codes, presumably generated by ADO.Net or the provider.

What I really need is a list of these error codes. Does anyone know where I
can find them?

In particular, if I get a timeout due to a locked table, the SqlError.Number
and SqlEcxepiton.Number is -2. Is this error code used only for timeouts?

Gary
-----Original Message-----
From: Marsh, Drew [mailto:[EMAIL PROTECTED]]
Sent: 30 January 2003 18:56
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Extracting SqlServer error codes using
SqlC ommands


Booth, Bill [mailto:[EMAIL PROTECTED]] wrote:

> Hmmm, It looks like the NativeError property would give you
> what you want but I don't see it in SQLClient. I can just
> find it as a property of OleDb or ADO 2.7 errors.
>
> "The NativeError property on a Error object is used to
> retrieve the database-specific error information for a
> particular Error object. Native error codes that originate
> from the OLE DB Provider through ADO to the ADO NativeError property."

I believe the SqlException::Number[1] property is what you're looking for:

<snip>
Property Value
The number that identifies the type of error.

Remarks
This number corresponds to an entry in the master.dbo.sysmessages table.

This is a wrapper for the Number property of the first SqlError in the
Errors property.
</snip>

HTH,
Drew

[ .NET MVP | weblog: http://radio.weblogs.com/0104813/ ]

[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemDataSqlClientSqlExceptionClassNumberTopic.asp

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


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