At times it may be necessary to change the data of a Recordset with totally different data from the same or different tables and even from a different connection. One way is to read the new data into a new recordset and swap with the present recordset.
It is much easier to read the different data into the same recordset in this manner:
If this change is made while the recordset is being browsed, the Browse should be able to handle the change smoothly, which was not possible till FWH18.04.
FWH 18.05 handles the change smoothly, as in this sample:

It is much easier to read the different data into the same recordset in this manner:
oRs:Close()
oRs:Source := cNewSQL
oRs:ActiveConnection := oNewConObject
oRs:Open()If this change is made while the recordset is being browsed, the Browse should be able to handle the change smoothly, which was not possible till FWH18.04.
FWH 18.05 handles the change smoothly, as in this sample:
#include "fivewin.ch"
function Main()
local oCnMDB, oCnDBF, oCnFWH, oRs
local cSqlMDB, cSqlDBF, cSqlFWH
local oDlg, oBrw
oCnMDB := FW_OpenAdoConnection( "c:\fwh\samples\xbrtest.mdb" )
oCnDBF := FW_OpenAdoConnection( "c:\fwh\samples\" )
oCnFWH := FW_DemoDB( "ADO" )
cSqlMDB := "SELECT ID,FIRST,CITY,SALARY FROM CUSTOMER"
cSqlDBF := "SELECT * FROM STATES"
cSqlFWH := "SELECT * FROM annual"
oRs := FW_OpenRecordSet( oCnMDB, cSqlMDB )
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL
@ 60, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS ;
CELL LINES NOBORDER
oBrw:CreateFromCode()
@ 10, 20 BTNBMP PROMPT "ADO-MDB" SIZE 100,30 PIXEL OF oDlg FLAT ;
ACTION ReadNewData( oBrw, cSqlMDB, oCnMDB )
@ 10,140 BTNBMP PROMPT "ADO-DBF" SIZE 100,30 PIXEL OF oDlg FLAT ;
ACTION ReadNewData( oBrw, cSqlDBF, oCnDBF )
@ 10,260 BTNBMP PROMPT "ADO-MYSQL" SIZE 100,30 PIXEL OF oDlg FLAT ;
ACTION ReadNewData( oBrw, cSqlFWH, oCnFWH )
ACTIVATE DIALOG oDlg CENTERED ON INIT oBrw:SetFocus()
oCnMDB:Close()
oCnDBF:Close()
oCnFWH:Close()
return nil
function ReadNewData( oBrw, cSql, oCn )
WITH OBJECT oBrw:oRs
:Close()
:Source := cSql
:ActiveConnection := oCn
CursorWait()
:Open()
END
WITH OBJECT oBrw
:SetADO( oBrw:oRs, .t. )
:SetFocus()
END
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India