Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Customize SQL error message for VB.NET App...
Customize SQL error message for VB.NET App use
Rate Topic
Display Mode
Topic Options
Author
Message
crux1187
crux1187
Posted Friday, October 05, 2012 6:12 AM
Forum Newbie
Group: General Forum Members
Last Login: Friday, October 05, 2012 10:02 PM
Points: 6,
Visits: 14
I am wondering if there is a way to overwrite or customize the system error thrown by SQL server. For example error message 521,instead of the default message you could customize or overwrite it with your own version of text.
What I wanted to achieve is to have my own error message displayed by a VB.NET App when SQL server throws an exception that there is a duplicate value in the table.
Post #1368969
Sean Lange
Sean Lange
Posted Friday, October 05, 2012 8:03 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 7:26 AM
Points: 8,548,
Visits: 8,205
crux1187 (10/5/2012)
I am wondering if there is a way to overwrite or customize the system error thrown by SQL server. For example error message 521,instead of the default message you could customize or overwrite it with your own version of text.
What I wanted to achieve is to have my own error message displayed by a VB.NET App when SQL server throws an exception that there is a duplicate value in the table.
Of course there is. Use Try-Catch in your VB app. Do you have a data layer? That would be the best place to capture this. All you need to do it catch the error and throw your own exception with your custom message.
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1369065
crux1187
crux1187
Posted Friday, October 05, 2012 10:06 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, October 05, 2012 10:02 PM
Points: 6,
Visits: 14
Can you provide me with some link or any code if there is any?
Post #1369379
Rajat Jaiswal-337252
Rajat Jaiswal-337252
Posted Sunday, October 07, 2012 12:27 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:43 PM
Points: 110,
Visits: 289
Hi,
In both SQL Server and VB.NET you have to use Try catch block.
What ever error you grab in SQL Server catch box just Raised it with RAISERROR syntax.
Now in VB.NET you can capture this and show or do what ever operation you want.
Post #1369555
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.