Thursday, June 07, 2007

MS SQL Server error messages*

Thursday, June 07, 2007 9:19:22 PM (GMT Standard Time, UTC+00:00)

Here's some interesting information I found online..

If you encounter an error (which becomes an exception in VS) returned to VS 2005 application from SQL Server and all you get is the error number, you can actually search SQL Server for the "deep description" behind the number itself. All you have to do is get the respective error number probably from the SqlException.Number Property and then check the sysmessages table in Master database.

Eg. Let's assume that in my ObjectDataSource1_Updated event, e.Exception contained a SqlException (it'll be at the InnerException level). You could get the sql error number (which we'll call @errorNumber) of that exception with SqlException.Number property. Next, you can run the following query SQL Server:

USE [master]
SELECT * FROM sysmessages WHERE error = @errorNumber;

Then.. you'll see the information on your error. Enjoy! :)

Related posts:
Select a random row in MS SQL...
Regular expressions
VS2005, ASP.NET 2 & DLLs, DLLs..
MS's ASP.NET and.. PHP
2-way databinding cascading drop down lists within a FormView
ApplicationName Property when customising providers

Comments are closed.