我有该代码使用 LINQ 调用存储过程以将一些数据保存到数据库中,然后从存储过程中返回两个变量。
[ASP.NET 代码]
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
这段代码工作得很好我现在想要使用 ADO 而不是 LINQ,我的问题是我不能像在 LINQ 中那样传递 ref 变量所以我怎么能使用 ADO