Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Adding a Record to a table, execution time

With all else equal, same table, same network, same number of users, same machine, same operating system etc..

Access 2003 front end and Access 2003 backend, linked tables, backend is on a server, front end is on each clients local machine.  

All values to be inserted in the new record are in temp variables, not being pulled from another table or query.

I'm trying to improve the efficiency of a client application.

I have used  both of the below techniques to add a record to a table.  In your experience, are either of these two techniques of adding a record to a table is better?  Or perhaps they are the same.
I realize the two examples refer to different tables, I am interested in processing time, reducing record locking etc..  between the two formats if they were being performed on the same table with all else being the same.
'
CurrentDb.Execute " insert into tblErrorLog " & _
              "( [ErrNum], [ErrText], [ErrUser], [ErrDateTime]  )  " & _
  "   values(" & passedErrNum & _
          ", " & Chr(34) & wkFullErrDesc & Chr(34) & _
          ", " & Chr(34) & wkErrUser & Chr(34) & _
          ", " & Chr(35) & wkErrDateTime & Chr(35) & _
          ")", dbFailOnError

Open in new window


or

'
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "tblBatchPaymentLog", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'
rs.AddNew
    '
    rs!NumberOfPayments = wkNumPaymentsCreated
    rs!AmountOfPayments = wkTotAmountPaymentsCreated
    rs!DateTimeOfBatch = thisBatchDateTime
    rs!UserCreating = GimmeUserName
    rs!BatchNum = thisBatchNumber
    '
rs.Update
'
rs.Close
Set rs = Nothing
'

Open in new window


Is there any advantage to either technique?
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Gustav,

I missed that altogether.  I just assumed the recordset method above was DAO rather than ADO.
Avatar of mlcktmguy

ASKER

Are you suggesting that DAO would be quicker than both of my examples?
Don't know, but often DAO is faster.

Why don't you check it out? It would only take you a few minutes ...

/gustav
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Based on the answers, I've left it as ADO for now.  Haven't had time to set up a comparison test yet.
Hmm ... it would have been nothing more than a copy-n-paste ...

/gustav
Still trying to get time
Thanks, all suggestions were helpful.  I couldn't determine any difference in the techniques for a single record.  When I tested with a batc of records, the biggest improvement was achieved using the transaction processing technique.