STATIC FUNCTION ADORECCOUNT(nWA,oRecordSet) //AHF
LOCAL aAWData := USRRDD_AREADATA( nWA )
LOCAL oCon := aAWData[WA_CONNECTION]
LOCAL nCount := 0, cSql:=""
IF oRecordSet:CursorLocation == adUseClient
nCount := oRecordSet:RecordCount
ELSE
IF LEN(aAWData[WA_INDEXES]) > 0 .AND. aAWData[WA_INDEXACTIVE] > 0
oRecordSet:close()
//Making it lightning faster
oRecordSet:CursorLocation := adUseServer
oRecordSet:CursorType := adOpenForwardOnly
oRsecordSetLockType := adLockReadOnly
//LAST PARAMTER INSERTS cSql COUNT(*) MUST BE ALL FIELDS BECAUSE IF THERE IS A NULL
//FIELD COUNTS RETURNS WRONG
cSql := IndexBuildExp(aAWData[WA_INDEXACTIVE],aAWData,.T.) //INCLUDE COUNT
msginfo("adoreccount 2 "+CSQL)
//LETS COUNT IT
oRecordSet:open(cSql,oCon)
nCount := oRecordSet:Fields( 0 ):Value
msginfo("adoreccount 3 NRREC "+CVALTOCHAR(NCOUNT))
oRecordSet:close()
//RETURNING TO DEFAULT DATA
oRecordSet:CursorType := adOpenDynamic
oRecordSet:CursorLocation := adUseServer //adUseClient never use ths very slow!
oRecordSet:LockType := adLockPessimistic
cSql := IndexBuildExp(aAWData[WA_INDEXACTIVE],aAWData,.F.) //.F. DONT INCLUDE COUNT
msginfo("adoreccount 4 "+CSQL)
oRecordSet:open(cSql,oCon)
ELSE
nCount := oRecordSet:RecordCount
ENDIF
ENDIF
RETURN nCount
AHF wrote:If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot.
Enrico Maria Giordano wrote:Antonio,AHF wrote:If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot.
Using adUseClient the performance is better than adUseServer!
EMG
Antonio Linares wrote:Antonio,
As far as I know oRs:RecordCount() returns the number of records of the recordset
so if you use a WHERE clause then you get less records.
Lets ask Mr. Rao
AHF wrote:What DB you use?
AHF wrote:adUseClient would be much easier for adordd (bookmarks etc) but everything I read covering this indicates that adUseClient its much slower and should be avoid.
AHF wrote:Please note that the I'm using SELECT * FROM ... in adordd thats its really not good SQL practice but compatibility much be achieved.
Enrico Maria Giordano wrote:AHF wrote:Please note that the I'm using SELECT * FROM ... in adordd thats its really not good SQL practice but compatibility much be achieved.
???
SELECT * FROM is the base of all SQL queries. What else would you want to use?
EMG
AHF wrote:I mean avoid loading all the fields instead of just the ones we need for the task.
Enrico Maria Giordano wrote:AntonioAHF wrote:I mean avoid loading all the fields instead of just the ones we need for the task.
Ok, but what if I need all the fields?
EMG
AHF wrote:Then SELECT colname FROM table unfortunatly in adordd its always all the fields! Its the price for no code change.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 96 guests