pujain

pujain

  • NA
  • 6
  • 0

Accessing Stored procedure from Application

Jul 26 2006 1:07 PM
I have stored procedure

CREATE  PROCEDURE [dbo].[MyProcedure]
@Order_ID               int,
@ReturnMessage  varchar(250) OUTPUT
AS

If exists(select Fname from table where condition)
Begin
Insert into Table1(Fname)
               values(
Select @ReturnMessage ="It exists and Fname inserted"
return @ReturnMessage
End
Select @ReturnMessage ="It does not exists"
return @ReturnMessage
GO




I want to call this Procedure from C#Application & return the valueof ReturnMessage in my application

SqlParameter paramOrderId = new SqlParameter("@Order_ID", SqlDbType.Int);

paramOrderId.Value = Order_ID;

SqlParameter paramRetMsg = new SqlParameter("@ReturnMessage", SqlDbType.Int );

paramRetMsg.Direction = ParameterDirection.Output;

ReturnMessage = Convert.ToInt32(SqlHelper.ExecuteScalar(ds._conStringCCR, CommandType.StoredProcedure, "MyProcedure", paramOrderId, paramRetMsg));


and I am not able to return the value to the application .

Please let me know whats wrong.

Answers (4)