我正在以这种方式从Excel执行存储过程:
Sub SPROCmain()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open connString()
conn.CommandTimeout = 0
rs.ActiveConnection = conn
rs.Open("EXECUTE [datamart].[dbo].[Pop_Main]")
MsgBox t
Set conn = Nothing
Set rs = Nothing
End Sub
它工作正常,将数据转储到某些表中供以后使用。有没有办法让我从存储过程中获取返回值,或者我是否必须选择设置新ADODB.Command
的路径?
答案 0 :(得分:0)
突然间这一切都有意义......
Sub SPROCmain()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open connString()
conn.CommandTimeout = 0
rs.ActiveConnection = conn
rs.Open ("DECLARE @return_value int " _
& "EXEC @return_value = [datamart].[dbo].[Pop_Main] " _
& "SELECT 'Return Value' = @return_value")
MsgBox rs.GetString
Set conn = Nothing
Set rs = Nothing
End Sub