Skip to content

Accessing return values(integer ) of stored procedure

pujain

Asked Jul 31, 2006, 6:26 AM EDT1 answer
Share
LinkedInX

I have a stored procedure
CREATE PROCEDURE Test
@ReturnVal   int  Output
AS
if exists(Select 1 from Business where Business_ID= '43')

Return  2
else
Return  3
GO




public static int myFunction(int Order_ID)

{

DataAccess ds = new DataAccess();
int ReturnMessage = 0;

try

{

System.Data.SqlClient.SqlParameter paramRetMsg = new SqlParameter("@ReturnVal", SqlDbType.Int);

paramRetMsg.Direction = ParameterDirection.Output;

/ReturnMessage = Convert.ToInt32 (SqlHelper.ExecuteNonQuery (ds._conStringCCR, CommandType.StoredProcedure, "Test" , paramRetMsg ));

}

catch(SqlException ex)

{

ExceptionManager.Publish(ex);

}

return ReturnMessage ;

 }

 I am not able to return 2 or 3 from the stored procedure .
Please let me know .
Thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I believe that the sql query in the stored procedure is not returning any value.You can test the query.
     
    0