Garrett Daniel DeMeyer
Garrett Daniel DeMeyer

Reputation: 931

Does Closing A RecordSet in VB 6.0 Update the Database?

I am converting VB 6.0 code to VB.Net. In the VB 6.0 code I see the following use of a recordset

varFields = Array([set of column names])
varData = Array([matching data])
recordset.Open "[a query that will return 0 results]", connection, adOpenDynamic, adLockOptimistic
recordset.AddNew varFields, varData
recordset.Close

As I understand it, with adOpenDynamic, this will not update the database with out a call to Update.

Could someone explain to me if this set of code is doing anything?

Thank you

Upvotes: 2

Views: 439

Answers (1)

GSerg
GSerg

Reputation: 78185

Yes, the code is valid.

As documented:

In immediate update mode ... If you pass the Fieldlist and Values arguments, ADO immediately posts the new record to the database (no Update call is necessary); the EditMode property value does not change (adEditNone).

Upvotes: 3

Related Questions