General discussion

  • Creator
    Topic
  • #2307483

    how save all changes to database in VB?

    Locked

    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

All Comments

  • Author
    Replies
    • #2745721

      Reply To: how save all changes to database in VB?

      by sachin ·

      In reply to how save all changes to database in VB?

      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

      • #2745674

        Reply To: how save all changes to database in VB?

        by khalid ·

        In reply to Reply To: how save all changes to database in VB?

        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

    • #3379628

      Reply To: how save all changes to database in VB?

      by rrv ·

      In reply to how save all changes to database in VB?

      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
      :DBErr
      msgbox Err.Description
      DB.RollbackTrans
      ———————————–
      All the best
      RV

    • #2680137

      Reply To: how save all changes to database in VB?

      by khalid ·

      In reply to how save all changes to database in VB?

      This question was closed by the author

Viewing 2 reply threads