General discussion

Locked

how save all changes to database in VB?

By khalid ·
I have making one program by Viusal Basic 6 and I using Access database (using ADO) but when I doing save change to the record like
adoprimaryRS.update
it's not saving realy until I close the form and open it again
(I mean if I ad new record and do update and I try to do query to new value which I Add (New) it can't find until I close the form and open again)
I try to use (requery) method but it's same
I hope you understand me and can help me thank you

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by sachin In reply to how save all changes to d ...

set rs=createobject("ADODB.recordset")
' Read all the records from the first table
sql="select * from TableA"
rs.open sql, Conn
while not rs.eof
total=0
' Get all the info from Table A
salesfigure1=request("salesfigure1")
salesfigure2=request("salesfigure2")
total=salesfigure1+salesfigure2
id=rs("id")
sql2="Update TableB set salesfigure=" & total &" where id=" & id
Conn.execute sql2
rs.movenext
wend

*************8
change the code as per your requirement

Collapse -

by khalid In reply to

I don't know what is the relation between my question and your answer .. sure you didn't understand what I mean
so I'll explane again
let say I have one form related to two table (from db)
first one (master) second table is (details) so whaen I add new record to the master and do update for new record then I try to make query for the New record I had saved the new value not coming until I close the form or close the DB and open again
.... thanks

Collapse -

by RRV In reply to how save all changes to d ...

In the ADODB connection use .Isolationlevel=adXactReadCommitted and .Mode=adModeShareDenyNone and .Cursorlocation=adUseClient

In the subroutine where you write the data to the table start like below. Assume connection is called DB.
-------------------------------------
On error goto DBErr
DB.BeginTrans
//write your data to table.
DB.CommitTrans
//query the new table with data
BErr
msgbox Err.Description
DB.RollbackTrans
-----------------------------------
All the best
RV

Collapse -

by khalid In reply to

Poster rated this answer.

Collapse -

by khalid In reply to how save all changes to d ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums