Subject Re: begintrans()
From Mustansir Ghor <>
Date Tue, 06 Dec 2022 05:52:48 -0500
Newsgroups dbase.getting-started

Dear Mervyn Sir

Great, 100% clear. Thank you

Below is my Save function

   function PBSAVE_onClick()

          sleep 0.5
     until form.qsales.rowset.lockset()
    m1 =str(val(form.qsales.rowset.fields["sno"].value)+1,6) // Getting the Serial no for the new record. Not using autoinc (my reservation)
                m7 = "TSH"
                m3 = datetime()
                m4 = _app.session.user()
                m5 = form.etotala.value
                m6 = form.edrem.value        

           insert into :plastic:XORDERA (sno,sdate,custcode,op,remark,invtype,loc) values(:m1,:m3,:m2,:m4,:m6,:m7,:m8) // this is same file that is assign to query qsales used in lock and unlock
                form.qtempsal.rowset.first() // in this is query temporary table used in local computer
                do while not form.qtempsal.rowset.endofset  
                 with (form.qtempsal.rowset)
                  fields["sno"].value=m1   //Serial no is assigned to each record here        
         upd = new updateset()          
          upd.source=form.qtempsal.rowset // Temporary table
          upd.destination=form.qsalesi.rowset //Child table in the server for master XorderA
          upd = null
         class::novprint()  // the order goes for printing        
      form.poslocal.emptytable("tempsal")  //temporary local table is emptied     

Anybody pls guide me how to incorporate Try and Endtry with database begintrans(), Commit() and rollback() to enhance my data saving function

Best Regards

Mervyn Bick Wrote:

> On 2022/12/06 11:18, Mustansir Ghor wrote:
> ..
> > However, Below text is copied from dbase help. Here why is the command form.rowset.parent.database.begintrans() and not form.database.begintrans()
> >
> > try
> >     form.rowset.parent.database.beginTrans( ) // Begin the transaction
> >     form.rowset.parent.database.commit( ) // If you got this far, there were no
> > catch ( Exception e ) // The parameter receives the Exception object that describes
> >     form.rowset.parent.database.rollback( ) // Undo any changes that did take
> > endtry
> >
> Although it's not usual, a form may have more than one database object
> and each database object may have more than one query (and as a result
> more than one rowset) associated with it.
> If you know which database associated with the query, and hence the
> rowset you are working with, then by all means use
> form.oDatabase.begintrans()
> Although a form may have several rowsets in play only one can be
> assigned to the form's rowset property.
> Example code in the help file needs to be fairly universal.  In this
> case the author is using the rowset assigned to the form's rowset
> property.  He does not, therefore, need to name the query. By working
> back up the "parentage" the author also specifies the correct database
> without needing to know it's actual name.
> If you need to work with a rowset not assigned to the form's rowset
> property then you need to specify the rowset in the command if you don't
> specify the actual database.
>     form.MyDatabase1.begintrans()
> or
>     form.customers1.rowset.parent.database.beginTrans( )
> Mervyn.