Wednesday, March 28, 2012

manage exception message

How to manage sql server runtime message to users understand it?

In my web form I added folowed code

If Session("Action") = "Edit" Then

Try

ObjectDataSource1.Update()

Catch ex As Exception

lblMessage.Text = ex.GetBaseException.Message

End Try

for manage user input for update the record.

This is message returned by sql server 2005

The UPDATE statement conflicted with the REFERENCE constraint "FK_DEVIZE_RELATION__DRZAVE". The conflict occurred in database "Trgo2006", table "dbo.Devize", column 'Drzava'. The statement has been terminated

This message not understand for users. How to manage messages retrned by sql server, or prepare exception to return message understanded for users.

YOu could build a generic wrapper class for Sqlexceptions like this one mentioned here:

http://weblogs.asp.net/guys/archive/2005/05/20/408142.aspx

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment