Action execute when at bottom of xbrowse

Action execute when at bottom of xbrowse

Postby Marc Vanzegbroeck » Tue Feb 21, 2012 10:29 am

Hello,

Is it possible to execute an action when the last row is selected in xbrowse?
I want to load a some data from the server and add them to the current file to improve network-speed.

Thanks,
Marc


Hello,

I'm using SQlite, and for browsing the data I make a query or the database that is located on the server, and store the fields I want browse, in a temporary dbf-file on the a local path.
Untill now I had no problems, but I created a testtable of 120000 records and the proces to read the data from the server into a temporary file takes a long time.
Is there a faster way to do it? I was thinking first read only 100 records, show them, and then reading the rest into the background and add them to the temporary database. Does anyone created something like that already?

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Action execute when at bottom of xbrowse

Postby Rick Lipkin » Tue Feb 21, 2012 1:46 pm

Marc

Just a quick thought .. would it be possible or practical to have a server side task that goes out every hour or so and builds\re-builds your .dbf temp table for your application to access ?

This would solve your 'on-demand' client side software to build each time .. and give you a near time access to your records?
.............

As far as a routine to build your records in real time I would do something like this :

create a temp .dbf

Open your sql-lite recordset using ADO .. something like this

cSQL := "SELECT * FROM YourTable"

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic

TRY
oRs:Open(cSQL,< sql-lite connection string > )
CATCH oErr
Close Temp
MsgInfo( "Error in Opening YourTable table" )
RETURN(.F.)
END TRY

select 1
Use temp excl
zap

oRs:MoveFirst()

Do while .not. oRs:eof

Select temp
append blank

temp->field1 := oRs:Fields("field1"):Value
temp->field2 := oRs:Fields("field2"):Value
...
...

oRs:MoveNext()

Enddo

select temp
dbCommit()

oRs:Close()

select temp //// use in your app


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2628
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Action execute when at bottom of xbrowse

Postby Marc Vanzegbroeck » Tue Feb 21, 2012 4:44 pm

Rick,

Thanks for your reply.
The routine to read the SQL-database into a local temporay datebase was already working fine.
The problem was that it take a long time to read them,if there are a lot of records.
That was the reason that I first wanted to load only the first 100 records, and read only the rest I they want to show the rest.
That piece of the program shows all the orders of a company. Normaly the customer in only intrested in the last orders, but sometimes he want to go more back in time.
I can also make a setting of how many orders must be displayed, and he want more, he can change it.
But I thought it would be nice that the are automaticly will be loaded if he is at the end of the browse.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Action execute when at bottom of xbrowse

Postby Gale FORd » Tue Feb 21, 2012 5:14 pm

I have thought about some changes to the browse scroll bar for some time.
If you are scrolling through a large amount of filtered/scoped data, it takes time to get the #records and position.
I think there should be an option that allows for page scrolling only.
The thumb portion stays in the middle until you reach the bof or eof.
You can click on the bottom section to page down or the top section to page up. I think this would accomplish what you want.
You would just have to add your code the the skip routine.
In addition, the browse would not have to calculate the # records and the position in the database all of the time.
This would speed up the creation and updating of the browse.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Action execute when at bottom of xbrowse

Postby Rick Lipkin » Tue Feb 21, 2012 6:51 pm

Marc

I appreciate your answer .. are you using ADO to connect to your Sql-Lite database ? If so, I would HIGHLY recommend using the 'local cache' option when you create your recordset object. You might find you will not need to create a .dbf copy on the client.

Code: Select all  Expand view

oRs:CursorLocation := 3 // local cache
 


You will be absolutely amazed at how quickly you can scroll thru and page up and down using the local cache option .. If you do not specify Local cache you will be thrashing through records on the database side and that can be 'BRUTAL' .

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2628
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Action execute when at bottom of xbrowse

Postby Marc Vanzegbroeck » Tue Feb 21, 2012 7:48 pm

Rick,

I'm not using ADO to connect to my SQLIite database but the library http://www2.zzz.com.tw/phpbb2/viewforum.php?f=1&sid=7353c3fdd171bd916f2b8599265acf02

I had not noticed that the 'oRs:CursorLocation := 3 // local cache'-line in your example was for caching.
I don't know that there is also a cache-option in the library I'm using. I will verify that.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Action execute when at bottom of xbrowse

Postby nageswaragunupudi » Wed Feb 22, 2012 2:58 am

Assuming nTotRecs is already assigned with total number of records in the server database,
Please try including this function inside oBrw:bChange codeblock or in a timer.
Code: Select all  Expand view
if oBrw:nLen < nTotRecs .and. ;
   oBrw:BookMark + 2 * oBrw:nDataRows - oBrw:nRowSel - 1 > oBrw:nLen
      ReadAndAddNextChunk() // This is your function
   oBrw:KeyCount()
endif

I have not tested this code but I hope it works.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Action execute when at bottom of xbrowse

Postby Marc Vanzegbroeck » Wed Feb 22, 2012 11:53 am

Thanks Rao,

I will try it.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 13 guests

cron