Now i am going to tell You that how to make return from stored Procedure
Suppose this is my Stored Procedure
create Proc AddNewscrip
@unique as nvarchar(50),
as
if(@unique ='insert')
begin
if exists(select scripname from scripmaster where scripname=@scripname)
return 1
else
return 0
end
Now at .cs page You can retrive it like
SqlParameter returnValue = new SqlParameter("returnVal", SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnValue);
Now Open the Connection
conn.open();
cmd.ExecuteNonQuery();
conn.Close();
return Convert.ToInt32(returnValue.Value);
In this way you can get return value 0 or may be 1 depending on Your condition
Suppose this is my Stored Procedure
create Proc AddNewscrip
@unique as nvarchar(50),
as
if(@unique ='insert')
begin
if exists(select scripname from scripmaster where scripname=@scripname)
return 1
else
return 0
end
Now at .cs page You can retrive it like
SqlParameter returnValue = new SqlParameter("returnVal", SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnValue);
Now Open the Connection
conn.open();
cmd.ExecuteNonQuery();
conn.Close();
return Convert.ToInt32(returnValue.Value);
In this way you can get return value 0 or may be 1 depending on Your condition
No comments:
Post a Comment