【问题标题】:MS Access Error - Provider cannot be found. It may not be properly installedMS 访问错误 - 找不到提供程序。可能没有正确安装
【发布时间】: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


    【解决方案1】:

    您需要使用有效的提供程序。提供者不是数据库的名称。

    根据您安装的内容,可能会有不同的提供程序可用。 sqloledb 提供者是一个常见的提供者。

    cnnStr = "Provider=sqloledb;Data Source=test\SQL2012;Initial Catalog=DBSource;" & _
             "Integrated Security=SSPI;"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-10
      • 2023-03-25
      • 2018-11-25
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多