我正在尝试将VBA连接到sql server f。我正在使用Windows Server 2016数据中心和sql服务器管理工作室V17.3。因此,我在VBA参考
中使用了以下对象当我尝试在行下执行
Dim Cn As ADODB.Connection
我收到错误消息
Run time error -2147467259(80004005)
Automation error,Unspecified error
您能指导我解决此错误吗
答案 0 :(得分:1)
尝试一下
Sub GetData()
Dim cnDump As ADODB.Connection
Set cnDump = New ADODB.Connection
' Provide the connection string.
Dim strConn As String
'Use the SQL Server OLE DB Provider.
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=XXXX;Data Source=XXXX\XXXX;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=XXXX;Use Encryption for Data=False;Tag with column collation when possible=False;"
'Now open the connection.
cnDump.Open strConn
答案 1 :(得分:1)