Refreshing xbrowse when dataset is closed and re-opened
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Are you sure that the oBrw:refresh() is being called? I don't see how the display can be showing different records than the dialog, unless it wasn't refreshed.
Can you see the browse being repainted?
The only other possibility I can think of is that the dialog is not loading the current record.
James
Can you see the browse being repainted?
The only other possibility I can think of is that the dialog is not loading the current record.
James
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Refreshing xbrowse when dataset is closed and re-opened
James
I found re-using the same recordset variable worked just fine .. just after the recordset is reset did I need to reset the list box with yours and Rao's suggestion of oBrw:oRs := oRsTrip
I found re-using the same recordset variable worked just fine .. just after the recordset is reset did I need to reset the list box with yours and Rao's suggestion of oBrw:oRs := oRsTrip
Code: Select all | Expand
IF lOK = .F.
ELSE
oDLG := NIL
SysReFresh()
lOK1 := .F.
// re open a new recordset
DEFINE DIALOG oDlg ;
FROM 5, 8 to 10, 75 ;
TITLE "Please be patient " ;
STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME ) TRANSPARENT
cSAY := "Opening Initial TRIPS Data Recordset for Motorpool "+alltrim( xPOOL )
@ 1,10 SAY oSay var cSAY of oDLG
oDLG:bStart := { | | lOK1 := _OpenUm(oDlg ) }
ACTIVATE DIALOG oDLG CENTERED ;
ON PAINT GradientFill( hDC, 0, 0, odlg:nHeight, odlg:nWidth, xGrad1, .T. )
IF lOK1 = .F.
SysReFresh()
RETURN(.F.)
ENDIF
// here was the solution //
oBrw:oRs:= oRsTrip
oBrw:ReFresh()
SysReFresh()
ENDIF
oBrw:ReFresh()
SysReFresh()
xTITLE := "TRIPS Records Browse for Agency\Motorpool "+ALLTRIM(xAGENCY)+"\"+ALLTRIM(xPOOL)
oEMP:cTITLE(xTITLE)
oEMP:ReFresh()
SysReFresh()
RETURN( .T. )
- Armando
- Posts: 3271
- Joined: Fri Oct 07, 2005 8:20 pm
- Location: Toluca, México
- Been thanked: 2 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Tim and friends:
Perhaps I don't understand very well the problem but
Initialy I made a recordset (oRsHdr) with including only records of 2010 year and
with a spinner the user can retrive records of others years an the above code works
fine.
Best regards
Perhaps I don't understand very well the problem but
Code: Select all | Expand
STATIC FUNCTION FilHdr(nAmo,oBrw,aGets)
oRsHdr:Close()
oRsHdr:Source := "SELECT " +;
"hdrfac.*," +;
"cliente.cli_nom " +;
"FROM " +;
"hdrfac," +;
"cliente " +;
"WHERE " +;
"hdrfac.hdr_cli = cliente.cli_cli " +;
"AND " +;
"YEAR(HDR_FDE) = '" + STR(nAmo,4,0) + "' " +;
"ORDER BY " +;
"hdr_fac"
oRsHdr:Open()
oRsHdr:Refresh()
oBrw:Refresh()
aGets[1]:oJump := oBrw
RETURN(.T.)
Initialy I made a recordset (oRsHdr) with including only records of 2010 year and
with a spinner the user can retrive records of others years an the above code works
fine.
Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Rick,
Glad to hear you found a solution.
Here is a suggestion for a tiny improvement.
Regards,
James
Glad to hear you found a solution.
Here is a suggestion for a tiny improvement.
Regards,
James
Code: Select all | Expand
// here was the solution //
oBrw:oRs:= oRsTrip
// These are redundant since they are executed
// right after the ENDIF
// oBrw:ReFresh()
// SysReFresh()
ENDIF
oBrw:ReFresh()
SysReFresh()
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Refreshing xbrowse when dataset is closed and re-opened
James,Rao
Thanks for all your help !!
Rick
Thanks for all your help !!
Rick
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Armando,
Well, that is just too easy!
Where were you when we needed you?
Rick,
The only difference I see in his code is:
oRsHdr:Refresh()
I am making a note.
Would you mind testing it?
Regards,
James
Well, that is just too easy!
Where were you when we needed you?
Rick,
The only difference I see in his code is:
oRsHdr:Refresh()
I am making a note.
Would you mind testing it?
Regards,
James
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Refreshing xbrowse when dataset is closed and re-opened
James
The oRsTrip:ReFresh() did not work and here is the placement of the code :
The oRsTrip:ReFresh() did not work and here is the placement of the code :
Code: Select all | Expand
IF lOK = .F.
ELSE
oDLG := NIL
SysReFresh()
lOK1 := .F.
// re open a new recordset
DEFINE DIALOG oDlg ;
FROM 5, 8 to 10, 75 ;
TITLE "Please be patient " ;
STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME ) TRANSPARENT
cSAY := "Opening Initial TRIPS Data Recordset for Motorpool "+alltrim( xPOOL )
@ 1,10 SAY oSay var cSAY of oDLG
oDLG:bStart := { | | lOK1 := _OpenUm(oDlg ) }
ACTIVATE DIALOG oDLG CENTERED ;
ON PAINT GradientFill( hDC, 0, 0, odlg:nHeight, odlg:nWidth, xGrad1, .T. )
IF lOK1 = .F.
SysReFresh()
RETURN(.F.)
ENDIF
* oBrw:oRs:= oRsTrip // this does work
oRsTrip:Refresh() // does not work
oBrw:ReFresh()
SysReFresh()
ENDIF
oBrw:ReFresh()
SysReFresh()
xTITLE := "TRIPS Records Browse for Agency\Motorpool "+ALLTRIM(xAGENCY)+"\"+ALLTRIM(xPOOL)
oEMP:cTITLE(xTITLE)
oEMP:ReFresh()
SysReFresh()
RETURN( .T. )
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Rick,
Thanks for testing it. Maybe Armando has an idea?
James
Thanks for testing it. Maybe Armando has an idea?
James
- Armando
- Posts: 3271
- Joined: Fri Oct 07, 2005 8:20 pm
- Location: Toluca, México
- Been thanked: 2 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
James and friends:
I'm so sorry, too much work and later deserved vacations
Perhaps this code can help a little bit more.
This is the original code to create the initial recordset
And this is the code with the spinner to let to choice a diferent year
Finaly the code to refresh the recordset and to show the new browse.
And that's all folks.
Best regards
I'm so sorry, too much work and later deserved vacations

Perhaps this code can help a little bit more.
This is the original code to create the initial recordset
Code: Select all | Expand
oRsHdr:CursorLocation := adUseClient
oRsHdr:LockType := adLockOptimistic
oRsHdr:CursorType := adOpenDynamic
oRsHdr:Source := "SELECT " +;
"hdrfac.*," +;
"cliente.cli_nom " +;
"FROM " +;
"hdrfac," +;
"cliente " +;
"WHERE " +;
"hdrfac.hdr_cli = cliente.cli_cli " +;
"AND " +;
"YEAR(HDR_FDE) = '" + STR(nAmo,4,0) + "' " +;
"ORDER BY " +;
"hdr_fac"
And this is the code with the spinner to let to choice a diferent year
Code: Select all | Expand
REDEFINE GET aGets[ 1] VAR nAmo ID 101 OF oDlg UPDATE;
PICTURE "9999" SPINNER;
ON CHANGE (FilHdr(nAmo,oBrw,aGets),oBrw:SetFocus(),oBrw:GoTop(),oDlg:UPDATE());
MESSAGE "Año de las facturas a mostrar"
Finaly the code to refresh the recordset and to show the new browse.
Code: Select all | Expand
STATIC FUNCTION FilHdr(nAmo,oBrw,aGets)
oRsHdr:Close()
oRsHdr:Source := "SELECT " +;
"hdrfac.*," +;
"cliente.cli_nom " +;
"FROM " +;
"hdrfac," +;
"cliente " +;
"WHERE " +;
"hdrfac.hdr_cli = cliente.cli_cli " +;
"AND " +;
"YEAR(HDR_FDE) = '" + STR(nAmo,4,0) + "' " +;
"ORDER BY " +;
"hdr_fac"
oRsHdr:Open()
oRsHdr:Refresh()
oBrw:Refresh()
aGets[1]:oJump := oBrw
RETURN(.T.)
And that's all folks.
Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
There is no Refresh method for RecordSet in ADO.
There are only ReSync() and ReQuery() methods.
You can change the source of a RecordSet ( oRs:Souce := <cNewSource> ) and do oRs:ReQuery(), but not Refresh().
This can work:
oBrw:oRs:Source := <cNewSQL Statement>
oBrw:oRs:Requery()
oBrw:GoTop()
oBrw:Refresh()
There are only ReSync() and ReQuery() methods.
You can change the source of a RecordSet ( oRs:Souce := <cNewSource> ) and do oRs:ReQuery(), but not Refresh().
This can work:
oBrw:oRs:Source := <cNewSQL Statement>
oBrw:oRs:Requery()
oBrw:GoTop()
oBrw:Refresh()
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Rao,
Well, that would explain it. Apparently, Armando is not using ADO.
However, shouldn't oRS:refresh() error out if that method doesn't exist?
James
Well, that would explain it. Apparently, Armando is not using ADO.
However, shouldn't oRS:refresh() error out if that method doesn't exist?
James
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
James Bott wrote:Rao,
Well, that would explain it. Apparently, Armando is not using ADO.
However, shouldn't oRS:refresh() error out if that method doesn't exist?
James
If it is a recordset, it will error out
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Armando
- Posts: 3271
- Joined: Fri Oct 07, 2005 8:20 pm
- Location: Toluca, México
- Been thanked: 2 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
James:
Yes, I'm using ADO, xHarbour, MySql & FWH810. And not problem at all with
oRsHdr:Refresh()
Regards
Yes, I'm using ADO, xHarbour, MySql & FWH810. And not problem at all with
oRsHdr:Refresh()
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Mr. James
The command is same is oBrw:SetAdo( oRs, ...... )
There is no need to say oBrw:cAlias := nil.
The entire problem here is in the variable management.
I provide here a simple sample for switching recordset ( as long as columns are the same )
Please try this code after changing FWPATH, if necessary.
On selecting a State in the combobox, the recordset is closed and opened with a new Sql and browse is refreshed.
This syntax is OK; it is the same as oBrw:setADO( oRS )
Note that a recordset is not an alias. There is no alias used when using a recordset. In TWbrowse you had to set cAlias to nil to prevent it erroring--this was really a workaround for a bug.
The command is same is oBrw:SetAdo( oRs, ...... )
There is no need to say oBrw:cAlias := nil.
The entire problem here is in the variable management.
I provide here a simple sample for switching recordset ( as long as columns are the same )
Code: Select all | Expand
#include 'fivewin.ch'
#include 'xbrowse.ch'
#define FWPATH "c:\fwh\samples\"
static oCn
function Main()
local cStr := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ;
FWPATH + ;
";Extended Properties=dBASE III;User ID=Admin;Password=;"
local cSql := 'SELECT FIRST,CITY,STATE FROM CUSTOMER WHERE STATE = "?" ORDER BY FIRST'
local oDlg, oBrw, oRs
local cState := 'NY'
oCn := TOleAuto():New( "ADODB.Connection" )
oCn:Open( cStr )
oCn:CursorLocation := 3 // adUseClient
oRs := TOleAuto():New( "ADODB.RecordSet" )
oRs:Open( StrTran( cSql, '?', cState ), oCn )
DEFINE DIALOG oDlg SIZE 600,400 PIXEL
@ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
AUTOCOLS AUTOSORT RECORDSET oRs ;
CELL LINES NOBORDER
oBrw:CreateFromCode()
@ 10,240 COMBOBOX cState ITEMS { "AK", "AL", "AR", "AZ", "CA", "DA", "GE", "HI", "NY" } ;
SIZE 50,100 PIXEL OF oDlg ;
ON CHANGE ( ;
oBrw:oRs:Close(), ;
oBrw:oRs:Open( StrTran( cSql, "?", cState ), oCn ), ;
oBrw:GoTop(), oBrw:Refresh(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED ON INIT ( oBrw:SetFocus(), .f. )
return nil
Please try this code after changing FWPATH, if necessary.
On selecting a State in the combobox, the recordset is closed and opened with a new Sql and browse is refreshed.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Refreshing xbrowse when dataset is closed and re-opened
Armando wrote:James:
Yes, I'm using ADO, xHarbour, MySql & FWH810. And not problem at all with
oRsHdr:Refresh()
Regards
Yes. I tested and oRecSet:Refresh() does NOT error out.
But refresh method is not documented for ADO.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India