Update Table - SQL or Recordset Edit (1 Viewer)

lopiner

Registered User.
Local time
Today, 21:10
Joined
Jan 21, 2010
Messages
29
Hi, I'm relatively new to Databases and have been working on some projects. I have a doubt of what methods are more appropriate when updating or inserting data in a table. Here are the two methods that i use.

1. Open e snapshot recordset, calculate things and insert or update with sql the result in the table. Example:
Code:
Dim DataSet as DAO.Recordset
Set DataSet = CurrentDb.OpenRecordset("Table", dbOpenSnapshot)
CurrentDb.Execute "INSERT INTO Table VALUES (Example)"

2. Open a recordset and use the edit command to update it
Code:
Dim DataSet as DAO.Recordset
Set DataSet = CurrentDb.OpenRecordset("Table")
DataSet.Edit
DataSet("Field") = Example
DataSet.Update

I don't know which one is faster or more appropriate. any help is very appreciated.
Thanks in advance.
 

DCrake

Remembered
Local time
Today, 21:10
Joined
Jun 8, 2005
Messages
8,632
There are different schools of thought on this, however, I find the second option more flexible and easier to code. Conversely the first method allows you to yuse the dbFailOnError intellisence. Regarding speed, unless you bench test in your own environment as different networks behave differently, connections, band widths, etc can affect the overall performance, you will make the necessary decision yourself.
 

Users who are viewing this thread

Top Bottom