cannot read record immediatly after update

deell
10-20-2004, 08:34 PM
after the records are added and updated, then immediatly i want to read them by selecting sql, the records are not in recordset. after i wait for around 4 seconds and requery, then the records come out. my code here:


Dim rs as Recordset
set rs = db.OpenDatabase("Select * From myTable")
Do while ...
...
rs.AddNew
...
rs.Update
Loop
rs.Requery


records that just added not in the recordset.
if i sleep for 3,4 seconds, then only they only get into recordset.

How to solve this??
Thank you.

Dennis DVR
10-21-2004, 07:15 AM
perhaps adding a DoEvents would help but, avoid using it unless it's necessary because it would make the process slower.

deell
10-21-2004, 08:20 PM
perhaps adding a DoEvents would help but, avoid using it unless it's necessary because it would make the process slower.

it cant work. any other solution? pls help

nicktangri
10-21-2004, 10:02 PM
Hi

try adding rs.MoveNext or rs.MoveLast, or rs.MoveFirst according to where you are, before Loop

cheers

Dennis DVR
10-21-2004, 10:52 PM
it cant work. any other solution? pls help

can see we your current code for saving and querying? and perhaps putting it inside the transaction would also help (look at your MSDN about transaction "BeginTrans, CommitTrans,Rollback") and if the fields are not that many try to use the INSERT statement gainst your database object instead of using addnew method of recordset.


btw: if you have time you should switch to ADO object

MKoslof
10-22-2004, 05:57 PM
For better speed and performance, try using straight sql instead :). By using the connnection object's .execute method conduct an INSERT INTO or SELECT * INTO sql statement..then you don't have to open the recordset and loop until EOF.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum