How to access SQL Server from VBA in a non-deprecated way?

后端 未结 3 1415
囚心锁ツ
囚心锁ツ 2020-12-31 08:36

It appears that all ways to directly access an SQL Server database from a VBA project have been deprecated:

  • DAO with ODBCDirect: Support has been dropped with
3条回答
  •  清歌不尽
    2020-12-31 09:31

    When initializing an adodb.connection in vba we replaced

              .Provider = "sqloledb"
              .Properties("Data Source").Value = sServer
              .Properties("Initial Catalog").Value = sDB
              .Properties("Integrated Security").Value = "SSPI"
    

    with

               .ConnectionString = _
                   "DRIVER={ODBC Driver 11 for SQL Server}; " & _
                   "SERVER=" & sServer & "; " & _
                   "Trusted_Connection=Yes; " & _
                   "DATABASE=" & sDB & "; "
    

    That uses .Provider = "MSDASQL.1" but you don't have to add that.

提交回复
热议问题