FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Update data showed in xBrowse
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Update data showed in xBrowse
Posted: Wed Sep 11, 2024 12:31 PM

Hi guys,

I have a xBrowse where I show rows of a MySql Table. This module is opened in several computers at the same time and records are being modified.

What is the best way to keep updated the rows that are being shown in this xBrowse?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Update data showed in xBrowse
Posted: Wed Sep 11, 2024 01:08 PM
Code (fw): Select all Collapse
   oBrw:Refresh(.T.) ??
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Wed Sep 11, 2024 01:31 PM

Karinha,

No my friend, oBrw:Refresh(.t) doesn't help.

The records are being modified in other computers, so i wanted to know if there is a way to be notified when the records need to be updated in xbrowse, because they were modified in others computers.

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 06:55 AM

I use a refresh button with oBrw:oRs:Requery()

Maurizio

Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 10:59 AM

Than you Maurizio,

Nowaday, I'm doing like you.

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 11:43 AM

You could refresh the browse by using a timer (to read current data of changed items and if so refresh) so that changes on other computers will change the data on all computers.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 11:52 AM

Thank you Marc,

Yes, we're using a timer too. But I think xbrowser could have a method to Sync automatically all records that are been shown.

Look, not all the oRowset's records, just those that are visible right now in the xbrowser

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 12:35 PM

Maybe a autosync can be build .... I think from a earlier post from Mr. Rao that Xbrowse only updates the visible rows and not need to read the full rowset.

In that post we where talking about uptimised filters and indexes and Mr. Rao wanted to explain that in full theorie/praktic but due to time/work that item was not covered yet.

You probebli know that speed issues over LAN are gone once using FWH with Remote Desktop.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 12:38 PM

Yes, Something like an autosync would be great!

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 12:43 PM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 12:51 PM

Yes,

But, there he is doing autosyng in the same computer and I need it in different computers.

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 01:13 PM
No my friend, oBrw:Refresh(.t) doesn't help.
Obviously oBrw:Refresh() can not make oRs to read the records from the Server again.

Requerying frequently makes the application sluggish.

There is a less known method
Code (fw): Select all Collapse
oRowSet:Refresh()
This method refreshes only those records which are updated by other users on the network after the RowSet is updated last.
But this works only if the table contains a column that records "modified datetime"
Though it is very easy to create that kind of column using our library, I am sure most of users might not have created such column.
Code (fw): Select all Collapse
oRowSet:Resync() // --? lChanged
This method reads the current record only from the server and updates.
Returns if the record is changed by other users.
Code (fw): Select all Collapse
oRowSet:NetChanged( [RecNo], [@lDeleted] ) // -->lChanged
Code (fw): Select all Collapse
oBrw:bChange := { || If( oRs:NetChanged(), oBrw:RefreshCurrent(), nil ) }
When we are navigating the browse, this will update the row from the server. Not all visible rows but the current row.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 02:07 PM
Thank you Mr Rao, your advices are always great!
oRowSet:Resync() // --? lChanged
Here, oRowSet:Resync() is always returning .T., even the record was not changed.

Do you think is possible to do an option to verify all visible record in the xBrowse and update only those that were changed?
Nowaday, I'm doing it by this way:
Code (fw): Select all Collapse
LOCAL lTem:=.F.,nPos:=0,nRegAt := ::oTab:Recno()   
   
   DEFAULT bBloco := {|| .T.}   

   ::oTmr:DeActivate()
   ::oTab:Skip(::oLbx:nRowSel * (-1))
   DO WHILE nPos < ::oLbx:nDataRows .AND. .NOT. ::oTab:Eof()
      IF Eval(bBloco)
         lTem := .T.
         ::oTab:ReSync()
      ENDIF   
      nPos++
      ::oTab:Skip()
   ENDDO     ::oTab:GoTo(nRegAt)
   IF lTem
      ::oLbx:Refresh()
   ENDIF   
   ::oTmr:Activate()
But i believe it could be done better :(
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Update data showed in xBrowse
Posted: Thu Sep 12, 2024 02:25 PM
I'm using Eval(bBloco) because I have some status where a record can't be modified anymore, so if he is in this status, i don´t need resync it.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil

Continue the discussion