MS 访问错误 - 无法找到提供程序。可能没有正确安装
MS Access Error - Provider cannot be found. It may not be properly installed
我正在尝试从 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
当我 运行 函数时,出现以下错误
如有任何帮助,我们将不胜感激。
谢谢。
您需要使用有效的提供商。提供者不是数据库的名称。
根据您安装的内容,可能会提供不同的提供程序。 sqloledb
提供程序是一个常见的提供程序。
cnnStr = "Provider=sqloledb;Data Source=test\SQL2012;Initial Catalog=DBSource;" & _
"Integrated Security=SSPI;"
我正在尝试从 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
当我 运行 函数时,出现以下错误
如有任何帮助,我们将不胜感激。 谢谢。
您需要使用有效的提供商。提供者不是数据库的名称。
根据您安装的内容,可能会提供不同的提供程序。 sqloledb
提供程序是一个常见的提供程序。
cnnStr = "Provider=sqloledb;Data Source=test\SQL2012;Initial Catalog=DBSource;" & _
"Integrated Security=SSPI;"