I'm moving tables of data from sql-server into Excel.
I do not need to move through the record set only to grab the data and paste it into a worksheet.
Am I using the correct arguments for the recordset's Open
method?
Dim recSet As ADODB.Recordset
Set recSet = New ADODB.Recordset
aConnection.Open
recSet.Open stringSQL, aConnection, adOpenForwardOnly, adLockReadOnly, adCmdText
wb.Sheets(sName).Cells(1, 1).CopyFromRecordset recSet
recSet.Close
If Not (recSet Is Nothing) Then
If (recSet.State And 1) = 1 Then recSet.Close
Set recSet.ActiveConnection = Nothing
Set recSet = Nothing
End If
This is the approach that I've use to extract the data from MSSQLServer, maybe it will be useful for you: