Discussion:
Update database not occurring
(too old to reply)
Scott
2003-07-14 22:53:14 UTC
Permalink
Hi,

I'm writing an application using VB6 (sp5), ADO, MDAC 2.6, MSDE 1.0,
Windows98SE. My database was created using MS Access 2000, as a project
(SQL). I wrote a data conversion program and was able to populate the
database with data just fine using SQL statements. For the regular
application, I was planning on using the ADODB recordset update or
updatebatch methods.

My steps:
- I created a recordset just fine using a stored procedure.
- open method is called with a command object, cursor location is
client, cursor type is adopenstatic
- I disconnected the recordset by setting the active connection to nothing.
- Why? To be sure no updates happen 'til I'm ready.
- The user edits the data in textboxes bound to recordset fields.
- The user's edits appear in the recordset.
- To save, I reconnect the recordset by setting the active connection.
- I invoke the update method.

My Problem: The database isn't updated.

Pertinent info:
- The recordset is read/write.
- At this stage I'm working with one record in the recordset.
- I tried the recordset movenext and move methods with no change in
behavior.
- After the update method, the ADO connection errors.count is zero.

Questions:
- Any ideas what's wrong?
- Since it's SQL, am I limited to SQL commands?
- If yes, can I hand a stored procedure a recordset and autoupdate from
it?

Thanks for any help.
- Scott
David Wimbush
2003-07-17 10:23:59 UTC
Permalink
It's better to use more stored procedures to perform the updates. But
I think what's going wrong is that you should set the recordset's
LockType to adLockBatchOptimistic before you open it and call its
UpdateBatch method to perform the updates.
Scott,
By the phrase 'update method' do you mean that you build the required SQL to
update the database?
db.execute ("UPDATE table SET field = value, field = value, etc...;") for
example.
Ade
Scott
2003-07-17 11:49:11 UTC
Permalink
Had this sample laying around from a previous project,
Thank you for sharing your project, it's a great sample and it answered
several questions I had, like how to create a table programatically. I
found the answer to my problem. I was trying to move the recordset pointer
with the syntax ".move .bookmark, 1" but I guess ADO is intelligent enough
to not move if the targeted record is the same as the current. Once I
switched to movenext and moveprevious my database updated. Thanks again.

-- Scott

Loading...