|
-
Jul 22nd, 2005, 06:21 AM
#1
Thread Starter
New Member
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
-
Jul 22nd, 2005, 06:50 AM
#2
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..
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|