运行时错误2147467259(80004005)ODBC SQL Server不存在或访问被拒绝

时间:2017-08-10 09:33:41

标签: excel-vba vba excel

我是VBA的新手。当我尝试执行这段代码(由其他人编写)时,我在objMyconn.open收到错误:

Dim objMyConn As ADODB.Connection
Dim objMyCmd As ADODB.Command

Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set dependenciesRecordset = New ADODB.Recordset

dependenciesRecordset.CursorLocation = adUseClient 

objMyConn.ConnectionString = "Provider=MSDASQL;Driver=SQL Server;Server=aac-
srvsqldb02\db02;Database=mydatabase;UID=webreport;PWD=abcdefghijkl;"
objMyConn.Open

1 个答案:

答案 0 :(得分:0)

我假设驱动程序名称应介于{}之间:Driver={SQL Server}