Error code: "Data source name not found and no default driver specified"
The connection key works for an SQLConnection/Command statement. I am uncertain if it will work here.
Code
Sub AccessingSQL()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL_String As String
Dim StrConn As String
Set cn = New ADODB.Connection
StrConn="connectionstring"
cn.Open StrConn
Set rs = New ADODB.Recordset
rs.Open Source:="PlanetaryOrbits", ActiveConnection:=cn, _
CursorType:=adOpenKeyset, LockType:=adLockOptimistic, _
Options:=adCmdTableDirect
rs.MoveFirst
Do Until rs.EOF
If rs!Index = "104" Then
n=n+1
Cells(n+1,"C")=rs!idp
Cells(n+1,"D")=rs!JD
rs.Update
End If
rs.MoveNext
LoopCells(2, 2) = rs!idp
Cells(3, 2) = rs!JD
rs.Close
Set rs = Nothing
cn.Close
End Sub
Display More