With FWH builtin mysql/mariadb library, use the method
EditBaseRecord( [cFieldList], [lNew], [bEdit], [oBrw], [lLock] )
This method reads all fields from the database and offers for edit. When saved, the rowset in the memory is updated.
Notes:
1) The table must have a primary key.
2) The query should include the primary key.
Sample code:
#include "fivewin.ch"
function Main()
local oCn
local oRs, oDlg, oFont, oBrw, oBar, bEdit
oCn := FW_DemoDB()
oRs := oCn:RowSet( "select id, first, city, salary from customer" )
// The table SHOULD have a primary key.
// The query SHOULD include the primary key.
// bEdit := { |oRec| MyEditDialog( oRec ) }
// In your program, you design your own dialog
XBROWSER oRs
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,600 PIXEL TRUEPIXEL FONT oFont
DEFINE BUTTONBAR oBar SIZE 80,32 2010
DEFINE BUTTON OF oBar PROMPT "New" ACTION oRs:EditBaseRecord( nil, .t., bEdit, oBrw )
DEFINE BUTTON OF oBar PROMPT "Edit" ACTION oRs:EditBaseRecord( nil, .f., bEdit, oBrw )
@ oBar:nHeight, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oCn:Close()
return nil
You may test this first and then apply to your table