CURIOUS DAO VS ADO, very impressed

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

CURIOUS DAO VS ADO, very impressed

Post by sal21 »

Code: Select all

Option Explicit
Function Showado()

    On Error GoTo Err_Handle

    Dim cnStr As String
    Dim cn As ADODB.Connection
    Dim cnRs As ADODB.Recordset

    Dim sngTime As Single
    sngTime = Timer

    Set cn = New ADODB.Connection
    cn.Open _
            "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                                "Data Source=C:\DATABASE\VEO.mdb;" & _
                                                "Jet OLEDB:Engine Type=4;"
    Set cnRs = New ADODB.Recordset
    cnRs.Open "SELECT * FROM VER", cn

    With cnRs
        Do Until .EOF
            .MoveNext
        Loop
    End With

    sngTime = Timer - sngTime
    Debug.Print "ADO Time " & FormatNumber(sngTime, 3) & " S"

Err_Handle:
    cnRs.Close
    cn.Close
    Set cnRs = Nothing
    Set cn = Nothing

    Call Showdao

    If Err.Number <> 0 Then
        MsgBox (Err.Description)
    End If

End Function
Function Showdao()

    On Error GoTo Err_Handle

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Dim sngTime As Single
    sngTime = Timer

    Set db = DBEngine.Workspaces(0).OpenDatabase("C:\DATABASE\VEO.MDB")
    Set rs = db.OpenRecordset("SELECT * FROM VER", dbOpenDynaset)

    With rs

        .MoveLast
        .MoveFirst

        Do Until .EOF
            .MoveNext
        Loop

    End With

    sngTime = Timer - sngTime
    Debug.Print "DAO Time " & FormatNumber(sngTime, 3) & " S"

Err_Handle:
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

    If Err.Number <> 0 Then
        MsgBox (Err.Description)
    End If

End Function
see time execution:
ADO Time 0,594 S
DAO Time 0,109 S

ADO is approx slower 5 times vs DAO!

possible?

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CURIUOS DAO VS ADO, very impressed

Post by HansV »

DAO is the 'native' database engine of Microsoft Access. ADODB is more flexible though, it works with many types of data, not just databases.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

Re: CURIUOS DAO VS ADO, very impressed

Post by sal21 »

HansV wrote:DAO is the 'native' database engine of Microsoft Access. ADODB is more flexible though, it works with many types of data, not just databases.
in this case i work with my project on a 150.xxx/250.xxx records with Access....
I need to migrate my appliaction in DAO or not?

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CURIUOS DAO VS ADO, very impressed

Post by HansV »

It's worth a try - see if it works better.
Best wishes,
Hans