pujain

pujain

  • NA
  • 6
  • 0

Accessing return values(integer ) of stored procedure

Jul 31 2006 10:26 AM

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


Answers (1)