February 2, 2008 at 2:34 am
My stored procedure can return different things. My procedure will return a result set if everything went well, or else, it will return an integer error code. How can I trap the error code?
I mean to say for e.g. if on a line of code you have a line of code that says
return @errorcode ;
How do you trap the value the sql server? And how would you do the same in ado.net, if anyone knows. (I just want the logic involved in this...).
February 4, 2008 at 9:20 am
Example of Calling a SQL Server SP with an return parameter (@RC):
DECLARE @rc int
DECLARE @WinderReel int
DECLARE @JumboSet tinyint
DECLARE @CullTime smalldatetime
DECLARE @Diameter decimal(9,3)
EXECUTE @rc = [LabNet].[dbo].[jpCullSetFetch]
@WinderReel
,@JumboSet
,@CullTime OUTPUT
,@Diameter OUTPUT
ADO.Net:
moCmd = New SqlCommand("dbo.jpPricingSave", moCon)
moCmd.CommandType = CommandType.StoredProcedure
With moCmd.Parameters
.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
End With
moCmd.ExecuteNonQuery()
iRetVal = CType(moCmd.Parameters.Item("@RETURN_VALUE").Value, Integer)
February 5, 2008 at 3:46 am
Jay,
Thanks for the reply. Now how do you do this if you were to do it in sql server.
February 5, 2008 at 6:10 am
My reply had two parts:
1. How to do it in SQL Server
2. How to do it in ADO.Net
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply