Dim backvalue As Integer '返回值 Dim adocmd As New ADODB.Command adocmd.ActiveConnection = CurrentProject.Connection adocmd.CommandType = adCmdStoredProc adocmd.CommandText = "test01" 'test01 为存储过程名 adocmd.Parameters.Item("@parameter1").Value = str1 ' 赋值输入参数 adocmd.Parameters.Item("@par2").Value = 0 adocmd.Execute adocmd.Parameters.Item("@par2").Value '获得输出的参数
以上VB执行代码
ALTER PROCEDURE test01 (@parameter1 varchar(10),@par2 int output) AS declare @nowtime as varchar(10) set @nowtime = CONVERT(varchar(100),GETDATE(),23) insert into table1 (bh,zhi) values(1,@parameter1) insert into table1 (bh,zhi) values(2,@nowtime) insert into table1 (bh,zhi) values(3,@par2) if (@nowtime = @parameter1 ) set @par2 = 1 else set @par2 = 2 return
以上为存储过程,实现日期判断功能
原文链接:https://www.f2er.com/vb/261083.html