Page 1 of 1

MariaDB Recordset - amended

PostPosted: Mon Jun 25, 2018 8:30 am
by fraxzi
Hi All,

How do I determine if RecordSet has been modified?

I am directly modifying oRs:field using GET or this is not the right approach?

:D

Re: MariaDB Recordset - amended

PostPosted: Wed Jun 27, 2018 2:42 am
by nageswaragunupudi
Code: Select all  Expand view

aModifed := oRs:ModiCols()
xbrowser aModified
 


If you want to modify values of some fields and then save, oRs:<fieldname> := <newvalue> and then oRs:Save() is okay.
Even you can offer edit of records this way, but we recommend using Datarow, which is a lot safer and feature rich.

Code: Select all  Expand view

oRs := oCn:customer // we can quickly open a table like this also.
oRs:Edit()  // to edit current record
oRs:Edit( .t. ) // to append a new record
 


This offers edit with a default dilaog. You can have your own edit dialog this way.
Code: Select all  Expand view

oRs := oCn:customer
oRs:bEdit := { |oRec| MyEditDialog( oRec ) }
oRs:Edit()
....
...
function MyEditDialog( oRec )

   local lNew := oRec:RecNo == 0
   local oDlg

   DEFINE DIALOG oDlg ........
   <all your gets here>
   ACTIVATE DIALOG oDlg
return nil
 

I recommend this approach all through your program.
Please feel free to ask any clarifications.

Re: MariaDB Recordset - amended

PostPosted: Wed Jun 27, 2018 3:33 am
by fraxzi
Hi Mr. Rao,

I already started using this approach when modifying xBrowse Row (not all rows are displayed)
Code: Select all  Expand view

...
oRs:bEdit := { |oRec| MyEditDialog( oRec ) }
oRs:Edit()
...
 


Very much convenient approach.

As for oRs:Save(), which I directly edit oRs:field, use of oRec = oRs:Record() is most logical and safer.. I will revise my coding.

and by-the-way, is FWMaria RowSet Wiki aligned with FWH18.04? I couldn't find the oRs:Modicols() method..


:D


Thanks much!

Re: MariaDB Recordset - amended

PostPosted: Wed Jun 27, 2018 3:36 am
by nageswaragunupudi
I will review WIKI again. Most likely early July.

Re: MariaDB Recordset - amended

PostPosted: Wed Jun 27, 2018 3:39 am
by nageswaragunupudi
As for oRs:Save(), which I directly edit oRs:field, use of oRec = oRs:Record() is most logical and safer.. I will revise my coding.

I suggest you follow my template given above.

Just use oRs:Edit() or oRs:Edit(.t.)
When you are in xbrowse, use oBrw:EditSource() or oBrw:EditSource(.t.)
We provided many other alternatives, but what I suggested is the best way.

Sometime today I will post a detailed template for edit dialog.

Re: MariaDB Recordset - amended

PostPosted: Fri Jun 29, 2018 12:38 am
by fraxzi
Thanks Mr. Rao! :wink: