错误:初始化字符串的格式不符合OLE DB规范

时间:2018-01-31 09:01:12

标签: vba excel-vba excel

我收到错误

  

初始化字符串的格式不符合OLE DB规范。

此代码在.open行停止。

如何解决此问题?

Public Const sDEMAND_ROLE_GUID As String = "{6AA0B273-2548-49ED-9592-78243D4353AC}"

Public Const sSHAREPOINT_SITE As String ="https://eu001sp.domain.com/sites/"
Sub TestPullFromSharepoint()

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sConn As String
Dim sSQL As String
Dim ID As String

sConn = "Provider=Microsoft.ACE.OLEDB.12.0;DATABASE=" & sSHAREPOINT_SITE & ";" & _
"LIST=" & sDEMAND_ROLE_GUID & ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';"

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
    .ConnectionString = sConn
    .Open
End With
sSQL = "SELECT tbl.[name] FROM [Library Name] as tbl where tbl.[id] = 14"
rs.Open sSQL, cn, adOpenStatic, adLockOptimistic

End Sub

0 个答案:

没有答案