January 3, 2005 at 12:14 am
In my Stored Procedure an insert statement returns some error which I want to trap and return it back to the calling form.
how can i do this
Thanks
Sanjay Masawan
January 3, 2005 at 5:40 am
Directly under the INSERT statement have the following
IF @@ERROR <> 0
BEGIN
RETURN(@@ERROR)
END
This will change the RETURN code from the SP to be the error code and exit the sp. You will then just need to have a parameter of RETURN type in your application set to the RETURN of the sp and viola.
Now I know some people will say SET a variable = @@ERROR and RETURN the variable. 6 of 1, 1/2 dozen of the other
Good Hunting!
AJ Ahrens
webmaster@kritter.net
January 3, 2005 at 5:59 am
Piggy-backing on AJ, see, if this helps:
http://www.sommarskog.se/error-handling-II.html
http://www.sommarskog.se/error-handling-I.html
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
January 3, 2005 at 6:55 am
Is the front end Visual Basic 6? If it is, you may want to create a global subroutine to loop through the recordsets of the Stored Procedure. I use the following (error handling is in the calling code).
Public Sub ExecuteCommand(strCommandName As String)
Dim r As ADODB.Recordset
Set r = gdbData.Commands(strCommandName).Execute
While Not (r Is Nothing)
Set r = r.NextRecordset
Wend
End Sub
If the phone doesn't ring...It's me.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply