Hi,
I have a problem here. I'm using ADO in my VB programming. I created a function to add new record into a table("result"). It able to add 500 records into the table but takes 40 seconds to run the process. If compare with DAO method, it can run very fast(5 second). My PC is Pentium III 800Mhz. why ADO run so slow compare to DAO? Please help me? here is my code.
Thank you.
Function Connection()
Connection = "Provider=Microsoft.jet.OL
EDB.4.0;Da
ta source=" & App.Path & "\books.mdb;persist security info=false"
End Function
Function RunSearch()
Dim rst As ADODB.Recordset
Dim query As String
query = "select * from IdentMaster Where IdentNo=15000 ORDER BY IdentMaster.IdentNo"
Set rst = New ADODB.Recordset
rst.CursorType = adOpenStatic
rst.Open query, connect_string, , , adCmdText
Dim rst1 As New ADODB.Recordset
With rst1
.CursorLocation = adUseServer
.CursorType = adOpenStatic
.Open "Result", connect_string, adOpenStatic, adLockOptimistic, adCmdTableDirect
.Index = "PrimaryKey"
End With
If rst.RecordCount = 0 Then
MsgBox "Record not found!", vbInformation
Me.sfToolList.Refresh
Else
'delete all records in Result table.
Dim oRs As New ADODB.Recordset
Dim adoConn As ADODB.Connection
Set adoConn = New ADODB.Connection
adoConn.ConnectionString = Connection()
adoConn.Open
oRs.CursorLocation = adUseClient
oRs.Open "Delete * from Result", adoConn, adOpenKeyset, adLockOptimistic
rst1.Requery
i = 0
rst.MoveLast
intCount = rst.RecordCount
rst.MoveFirst
For i = 1 To intCount
If rst1.EOF Then
With rst1
.AddNew
!IdentNo = rst!IdentNo
!MachineManufacturerID = rst!MachineManufacturerID
!MachineTypeID = rst!MachineTypeID
!groupid = rst!groupid
.Update
End With
End If
rst1.Requery
rst.MoveNext
Next i
End If
Rst.close
Set rst=nothing
End Function
Start Free Trial