Page 1 of 1
To Mr. Rao xBrowse + FASTEDIT + RECORDSET
Posted: Sat Dec 07, 2019 6:17 pm
by Armando
Mr. Rao and friends:
Would you be kind enough to tell me an example of xBrowse using FASTEDIT with RECORDSET.
Best regards
Re: To Mr. Rao xBrowse + FASTEDIT + RECORDSET
Posted: Sun Dec 08, 2019 12:13 pm
by nageswaragunupudi
XBrowse syntax and functionality is identical whatever be the datasource, eg. DBF, TDatabase, ADO RecordSet, MySql/PostGre QueryObject, etc.
Please copy this sample program to your fwh\samples folder and build with buildh.bat or buildx.bat or any build????.bat
Please notice that XBrowse and TDataRow work exactly the same way with identical syntax for all datasources.
Code: Select all
#include "fivewin.ch"
REQUEST DBFCDX
static aSource := { "DBF", "TDataBase", "ADO.MSSQL", "MYSQL" }
static oCn, nSource, uData
//----------------------------------------------------------------------------//
function Main()
RDDSETDEFAULT( "DBFCDX" )
SET DELETED ON
SetGetColorFocus()
FWNumFormat( "E", .t. )
REPEAT
nSource := Alert( "SELECT DATASOURCE", aSource )
if nSource > 0
OpenData()
BrowseData()
CloseData()
endif
UNTIL nSource == 0
return nil
//----------------------------------------------------------------------------//
static function BrowseData()
local oDlg, oFont, oBar, oBrw
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 900,600 PIXEL TRUEPIXEL FONT oFont TITLE aSource[ nSource ]
DEFINE BUTTONBAR oBar OF oDlg SIZE 100,32 2007
DEFINE BUTTON OF oBar PROMPT "Add" ACTION oBrw:EditSource( .T. )
DEFINE BUTTON OF oBar PROMPT "Edit" ACTION oBrw:EditSource()
DEFINE BUTTON OF oBar PROMPT "Delete" ACTION oBrw:Delete()
DEFINE BUTTON OF oBar PROMPT "Excel" ACTION oBrw:ToExcel() GROUP
DEFINE BUTTON OF oBar PROMPT "Report" ACTION oBrw:Report()
DEFINE BUTTON OF oBar PROMPT "Close" ACTION oDlg:End() GROUP
@ 40,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE uData ; // Alias, TDatabase Object, RecordSet or MySql/PostGre query object
COLUMNS "ID", "FIRST", "CITY", "STATE", "AGE", "SALARY" ;
CELL LINES NOBORDER FOOTERS FASTEDIT
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
:Salary:nFooterType := AGGR_SUM
:MakeTotals()
//
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
static function OpenData()
do case
case nSource == 1
USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"
uData := ALIAS()
case nSource == 2
uData := TDataBase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
case nSource == 3
oCn := FW_MSSQLDB()
uData := FW_OpenRecordSet( oCn, "customer" )
case nSource == 4
oCn := FW_DemoDB()
uData := oCn:RowSet( "customer" )
endcase
return uData
//----------------------------------------------------------------------------//
static function CloseData()
if nSource == 1
( uData )->( DBCLOSEAREA() )
else
uData:Close()
if oCn != nil
oCn:Close()
endif
endif
return nil
//----------------------------------------------------------------------------//
Re: To Mr. Rao xBrowse + FASTEDIT + RECORDSET
Posted: Sun Dec 08, 2019 5:06 pm
by Armando
Mr. Rao:
Thanks.
Best regards