我正在将数据表从sql-server移动到Excel中。
我不需要通过记录集来获取数据并将其粘贴到工作表中。最快的ADO从sql-server复制粘贴表格到Excel
我是否使用正确的参数为记录集的Open
方法?
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
对我来说很好。 – 2015-01-26 23:30:51
根据[MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ms675544(v = vs.85).aspx),是的,你的论点是正确的。如果你的'stringSQL'不那么复杂,你的'RecordSet'不是那么大,这应该是即时的。 – L42 2015-01-26 23:35:11
@ L42从不超过5000行×10列? – whytheq 2015-01-26 23:40:30