if object_id('tb')is not null drop table tb
go
create table tb(ID int identity,[Name] varchar(10))
insert tb select 'A' union all select 'B' union all select 'C'
if object_id('pro_test','P')is not null drop proc pro_test
go
create proc pro_test
@ID int ,
@name varchar(10) output -----------
as
select @name=name from tb where id=@id
go
declare @name varchar(10)
exec pro_test 2,@name output
select @name
/*
----------
B*/
go
create table tb(ID int identity,[Name] varchar(10))
insert tb select 'A' union all select 'B' union all select 'C'
if object_id('pro_test','P')is not null drop proc pro_test
go
create proc pro_test
@ID int ,
@name varchar(10) output -----------
as
select @name=name from tb where id=@id
go
declare @name varchar(10)
exec pro_test 2,@name output
select @name
/*
----------
B*/
CREATE PROC Aa
AS
SELECT getdate()
RETURN 20
goDim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.ConnectionString = "...."
conn.OpenSet rs = conn.Execute("declare @a int;exec @a=aa;select @a x")
Debug.Print rs.NextRecordset.Fields(0).Value'此值即为返回值
as
retutn 1定义一个adocommand,
为它定义一个参数,参数类型为返回参数。
adocommand执行存储过程p后,得到刚才定义的参数的值就是了。