I've always used ADO when using Access databases but just recently I've taken over a project where DAO has been used.
I've extracted a module from the project to use is another project (which I started using ADO). The problem is the ADO code takes around 5 times longer than the DAO code.
I have attached a sample project which shows how much quicker the DAO code completes compared to the ADO code. The database is a cut down version of what is used so 5 times longer can equal a long wait....
It is slower because your technique is all wrong. I am amazed that it worked at all. You are basically opening a connection to the database each time you open a recordset. Not a good idea.
he got me lost with all that code with exclamations in it
lintz, ADO is the successor to DAO BTW ..
Opening a connection when you open the recordset is not the issue though.
Opening a connection when you open the recordset is not the issue though.
Really??? Did you look at the code I posted. That was basically the only change I made and look at the difference between the two times in his project and the one I posted.
Really??? Did you look at the code I posted. That was basically the only change I made and look at the difference between the two times in his project and the one I posted.
sorry my bad .. yeah i see now why he is getting the speed diff .
Got a little lost up in that code is all .. 4am and all
actually with all the tests above i was getting DAO as faster. ..
But when i put ADO in front of DAO then i ADO was faster
So basically its a timing issue ... is all.
also you can speed that ADO up where you have loops, using GetRows ..
And Stored Queries, as well as setting the variables ...
yeah 5am and im off to sleep in a minute, but basically get rows is like this ..
Example using a Stored Query ..
VB Code:
Set objRs = objConn.Execute("Execute sq_MyQuery", , adCmdText)
If Not objRs.EOF Then
arr = objRs.GetRows()
Set objRs = Nothing
iCnt = UBound(arr, 2)
For i = 0 To iCnt
sField0 = arr(0, i)
sField1 = arr(1, i)
'// do something
Next i
Else
Set objRs = Nothing
End If
Note - this is just one example of GetRows.
Basically it lets you grab all the results into an array ..
then just loop through the array.
This partilcular method is proabably the fastest loop ..
when you have alot of results ... it just spits it out at you.
hi Roy....
but during the loop in array is possible to know wath is the current filed name ...
similar:
Code:
Set objRs = objConn.Execute("Execute sq_MyQuery", , adCmdText)
If Not objRs.EOF Then
arr = objRs.GetRows()
Set objRs = Nothing
iCnt = UBound(arr, 2)
For i = 0 To iCnt
sField0 = arr(0, i)
debug.print namefiled of sField0
sField1 = arr(1, i)
debug.print namefiled of sField1
'// do something
Next i
Else
Set objRs = Nothing
End If
By the way, rather than replying to this old thread (and thus sending emails to everyone who has replied/subscribed) you should have posted a new thread.
By the way, rather than replying to this old thread (and thus sending emails to everyone who has replied/subscribed) you should have posted a new thread.
Sorry for:
By the way, rather than replying to this old thread (and thus sending emails to everyone who has replied/subscribed) you should have posted a new thread.
tks for explain
but really my qst is:
is possible to decide wath filed get from getrows array???
i dont need to gett all fileds from the statement but only PROVA1, PROVA3, ecc...
is possible to decide wath filed get from getrows array???
i dont need to gett all fileds from the statement but only PROVA1, PROVA3, ecc...
To specify which fields you want to be included in the Array use the 3rd argument of the GetRows method. The 3rd argument accepts an array of fieldnames or ordinal positions (or a single field/position).
Dim arrResults As Variant
arrResults = rsData.GetRows(, , Array("PROVA1", "PROVA3"))
arrResults = rsData.GetRows(, , Array(0, 2))
To specify which fields you want to be included in the Array use the 3rd argument of the GetRows method. The 3rd argument accepts an array of fieldnames or ordinal positions (or a single field/position).
Dim arrResults As Variant
arrResults = rsData.GetRows(, , Array("PROVA1", "PROVA3"))
arrResults = rsData.GetRows(, , Array(0, 2))