Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tracking how many records currently fetched (asynchronou
Message
From
08/10/2005 04:27:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/10/2005 03:48:45
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9
Database:
MS SQL Server
Miscellaneous
Thread ID:
01057402
Message ID:
01057408
Views:
9
This message has been marked as a message which has helped to the initial question of the thread.
>I need to fetch a very large amount of data from SQL Server, and want to be able to display a progress bar while the data is fetched.
>
>I'm using ASYNCHRONOUS mode with SQL PASS-THROUGH.
>
>What can I use to detect the number of records fetched at any one point? RECCOUNT() doesn't work as it attempts to finish collecting all records before it displays.
>
>The information must be available in VFP somewhere, not least because if SET STATUS BAR is ON and SET TALK is ON then the record counter counts up at the bottom of the screen.
>
>I use SQLSTRINGCONNECT to connect to the database, because I need to build the connection string dynamically - the system could connect to any number of databases.
>
>Any ideas?
>
>Mnay thanks
>Ben
>
>
>Code so far:
>
>
>cConnectString="Driver=SQL Server;Server=X;Database=X;UID=X;PWD=X"
>hConn=SQLStringConnect(cConnectString)
>SQLExec(hConn, "select count(*) AS rcount from verylargefile","rcount")
>nTotalRecordsToFetch=rcount.rcount
>
>lSQLResult=SQLSETPROP(hConn,"Asynchronous",.T.)
>llCancel = .F.
>lnResult = 0
>
>ON ESCAPE llCancel = .T.
>DO WHILE (!llCancel AND lnResult = 0)
>  lnResult = SQLExec(hConn, "select * from verylargefile","getreg")
>  DOEVENTS
>  IF USED("getreg")
>    nCurrentRecordsFetched=RECCOUNT("getreg") && DOESN'T WORK
>    ShowProgressBar(nCurrentRecordsFetched, nTotalRecordsToFetch)
>  ENDIF
>ENDDO
>IF (llCancel AND lnResult = 0)
>  SQLCancel(hConn)
>ENDIF
>SQLDisconnect(hConn)
>
CursorGetProp('RecordsFetched', 'myAlias')
If it's very large table then why are you using:
SQLExec(hConn, "select count(*) AS rcount from verylargefile","rcount")
That info is readily available in sysindexes.ie:
SQLExec(hConn, "select rowcnt from sysindexes"+;
 " where id=object_id('verylargefile') and indid<2",'rcount')
nTotalRecordsToFetch=rcount.rowcnt
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform