.NET severity and SQL severity differ -
08-02-2004
, 08:13 AM
According to manuals, SQLError.Class holds the severity level and
SQLError.Number the error's number, as in master.dbo.sysmessages.
I have obtained two error numbers that do not exist in the table: 11
(something like "General network error. Check the network's manual")
and 17 ("SQL Server does not exist or the access was refused"). Their
lack in the table is fine because upon network failure or SQL Server
being down the server is unable to send those messages and it's done
presumably via .NET. However, shouldn't the MSDN entry for
SQLError.Class be updated to include this information?
Another thing is the difference between the severity level stated in
the table and severity level returned by SQLError. I received error
#17142 "SQL Server has been paused. No new connections will be
allowed." In sysmessages this error has severity level 16, whereas
SQLError.Class returns the value of 14. While these levels are in the
same range named "errors that can be corrected by the user" (11-16),
they are not the same. What's the cause of this behavior? Is this a
bug? I can reproduce this by pausing the server and then calling [C#]:
SqlConnection conn = new SqlConnection("Persist Security
Info=False;Integrated Security=SSPI;database=master;server=.;Connect
Timeout=3");
try {
conn.Open();
} catch (SqlException e) {
SqlError err = e.Errors[0];
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Number: " + e.Number);
Console.WriteLine("Severity: " + e.Class);
} finally {
if (conn != null) conn.Close();
}
I am using SQL 2000 + VS .NET 2003 + .NET Framework 1.1.
lukasz |