【发布时间】:2019-01-13 05:53:31
【问题描述】:
我正在尝试从 MS Access 2007 在 MS SQL Server 2012 中执行存储过程。我已添加 Microsoft ActiveX 数据对象 2.8 库作为参考。 这是我的 VBA 代码:
Function Sproc()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim cmd As ADODB.Command
Dim cnnStr As String
Dim Rs As New ADODB.Recordset
Dim StrSproc As String
cnnStr = "Provider=test\SQL2012;Data Source=DBSource;" & "Initial Catalog=test;" & _
"Integrated Security=SSPI;"
With cnn
.CommandTimeout = 900
.ConnectionString = cnnStr
.Open
End With
With cmd
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = "[test]"
.Parameters.Append .CreateParameter("@ID", adInteger, adParamInput, , Me.ID)
End With
With Rs
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmd
End With
Set rst = cmd.Execute
End Function
当我运行该函数时,我收到以下错误
我们将不胜感激任何形式的帮助。 谢谢。
【问题讨论】:
标签: ms-access stored-procedures sql-server-2012 vba ms-access-2007