>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 rowcnt from sysindexes"+; " where id=object_id('verylargefile') and indid<2",'rcount') nTotalRecordsToFetch=rcount.rowcntCetin