|
代码如下,大约近30万条数据,跑下来需要好几十秒,有时候更长,请教一下有没有优化方案
dim xx( 1 to 300000,1 to 5)
tt = Timer
p = 1
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\192.168.1.10\share\test.mdb"
Set rs = New ADODB.Recordset
With rs
.Open "SELECT * FROM " & sjk & " order by bm", cn, 1, 1, adCmdText
'ReDim xx(1 To .RecordCount, 1 To 5)
While Not .EOF
If Not zd.Exists(UCase(CStr(.Fields("bm")))) Then zd.Add UCase(CStr(.Fields("bm"))), p
xx(p, 1) = .Fields("a") '
xx(p, 2) = .Fields("b") '
xx(p, 3) = .Fields("bm") '
xx(p, 4) = .Fields("c") '
xx(p, 5) = .Fields("d") '
p = p + 1
.MoveNext
Wend
End With
cn.Close
Set rs = Nothing
Set cn = Nothing
MsgBox Timer - tt
|
|