-
Edit data in DB, ADO
Hi :)
Wich ADO command should I use to edit data in a DB. If the value to be entered in the primary key column already exists data should be fetched, to view, and updated. Which command should I use to uppdate? I could use commanddb and a SQLstring. But I would rather pass an array, as in the addnew command.
kaaja :wave:
-
Re: Edit data in DB, ADO
Sounds like a recordset object, with an sql statement.
If it returns (.eof is false) then edit the record, update via the screen. Otherwise .EOF is true and you have no records. So use .addnew and do the same update part as in the edit.
Example code (one way)
Code:
strsql = "Sql statement to open"
rst.open strsql,currentproject.connection,2,3,1 (dynamic, optimistic, adcmdtext)
if rst.eof then
rst.addnew
rst("fieldnameID") = number to be added
endif
rst("otherfields") = txtfields
rst("otherfields") = txtfields
rst("otherfields") = txtfields
rst.update
rst.close
You need to add in error checking etc..