Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error handling

Author  Topic 

sha_agrawal
Starting Member

24 Posts

Posted - 2008-12-29 : 11:33:21
I am using VB6 and SQL Server 2000.
I have created a delete trigger. Which checks for :-

IF customer's transaction already exist, can't delete his name from Master.
How to show error using Trigger. it works but not able to show the message for user using VB6.

Similar problem with defining Constraint/primary key, whenever any such confict occurs my VB based sotware shows the error message generated by the SQL SERVER and shuts off. How to customise errors in SQL SERVER 2000.
Please help me.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-29 : 11:49:53
Use RAISERROR in the trigger to pass an error message to your appllication.

For the constraint/primary key, just grab the error number from the SQL Server message and code your application to watch for that error number and instead show a custom message to the user through your application.

What do you mean by shuts off though?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

revdnrdy
Posting Yak Master

220 Posts

Posted - 2008-12-29 : 11:55:13

Not exactly sure what your asking (specs unclear to me).

Is it possible you could take advantage of raiserror? These are custom error messages that you define.
[url]http://msdn.microsoft.com/en-us/library/aa238452(SQL.80).aspx[/url]

You could also code in a return value that VB could use to trap errors
SQl returns a 0 when no errors are detected.

IF (some_error_value > 0)
return 1 to caller (VB script)

I am not sure if @@error will help you but you can also look at that.


r&r


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-29 : 11:55:59
http://www.sommarskog.se/error-handling-I.html
Go to Top of Page
   

- Advertisement -