I am returning 0 and 1 from a stored procedure like following. How can I fetch it in c# asp.net file?
ALTER procedure [dbo].[crudprocedure]
@getusername varchar(20),
@getfirstname varchar(20),
@getlastname varchar(20),
@getaddress varchar(20)
as
begin
IF not exists (select username from crudtable where username=@getusername)
begin
insert into crudtable(username,firstname,lastname,address)
values (@getusername,@getfirstname,@getlastname,@getaddress)
return 0
end
else
return 1
end
If you’re using SQL Server – then try this code here:
Basically, since you’re sending back that value using
RETURN 1from the stored procedure, you need to add an additional parameter to yourSqlCommandobject that has a.DirectionofParameterDirection.ReturnValue.That parameter will be set to the value that you send back from the stored procedure using
RETURN ....