how to pass ref variable to a SQL stored Procedure using ADO.NET?
i have that code using LINQ to call a stored procedure to save some data
into database then return two variables from the stored procedure.
[ASP.NET code]
dbDataContext dbo = new dbDataContext();
dbo.AddNewDoctor(doctorName, email, password, ref DocId, ref result);
[SQL]
create PROCEDURE [dbo].[AddNewDoctor]
@doctorname nvarchar(100),
@email nvarchar(100),
@password nvarchar(MAX),
@docId int out,
@Result int out
AS
BEGIN
SET NOCOUNT ON;
declare @idCounter int
select @idCounter = count(*) from dbo.doctors
if EXISTS (select * from dbo.doctors where e_mail = @email)
begin
SET @Result = -1
set @docId= 0
end
else
begin
INSERT INTO [dbo].[doctors]
([doctor_id]
,[doctorname]
,[e_mail]
,[password]
VALUES
((@idCounter +1)
,@docotorname
,@email
,@password
)
SET @Result = 1
set @docId= (@idCounter + 1)
end
END
this code work very well what i want to do now to use ADO instead of LINQ,
the problem with me is that i can't pass the ref variable as in LINQ so
how can i do it using ADO
No comments:
Post a Comment