ADO RDD xHarbour
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: ADO RDD xHarbour
Antonio,
I am checking the properties and methods of the ADO Connection object:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Please do a MsgInfo( oADODB:State ) before opening the recordset
I am checking the properties and methods of the ADO Connection object:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Please do a MsgInfo( oADODB:State ) before opening the recordset
Re: ADO RDD xHarbour
Antonio,
We just found out that :
RecordCount isnt always accurate:
with adUseServer (cursor supported by the provider) always return the total nr of records in table even if there is a where clause in the select like Reccount()
with adUseClient (MS ccursor ) always return the true nr of rows in the recordset
Thus the OrdKeyCount mainly needed for scrollbars will not function properly with adUseServer cursor!
We just found out that :
RecordCount isnt always accurate:
with adUseServer (cursor supported by the provider) always return the total nr of records in table even if there is a where clause in the select like Reccount()
with adUseClient (MS ccursor ) always return the true nr of rows in the recordset
Thus the OrdKeyCount mainly needed for scrollbars will not function properly with adUseServer cursor!
Regards
Antonio H Ferreira
Antonio H Ferreira
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: ADO RDD xHarbour
Antonio,
Many thanks for your great feedback
Many thanks for your great feedback
Re: ADO RDD xHarbour
Antonio,
OrdKeyCount and RECORDCOUNT might be a problem!
The only way to solve this is to:
If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot. Not advisable!
IF we use adUseServer then with a WHERE clause ADO returns wrong RECORDCOUNT and OrdKeyCount!
The only solution we for this is :
If there is a WHERE clause we have to query the table with SELECT COUNT(*) FROM ctable WHERE ....
Thus in each RECORDCOUNT and OrdKeyCount values are correct.
We replace RECORDCOUNT by the following code:
Do you have any other alternative? This function its called a lot and I dont know what will be effect in the overall performance. In our small trials it seems ok but .....
I miss good old DBF or ADS:(
OrdKeyCount and RECORDCOUNT might be a problem!
The only way to solve this is to:
If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot. Not advisable!
IF we use adUseServer then with a WHERE clause ADO returns wrong RECORDCOUNT and OrdKeyCount!
The only solution we for this is :
If there is a WHERE clause we have to query the table with SELECT COUNT(*) FROM ctable WHERE ....
Thus in each RECORDCOUNT and OrdKeyCount values are correct.
We replace RECORDCOUNT by the following code:
Code: Select all
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
I miss good old DBF or ADS:(
Regards
Antonio H Ferreira
Antonio H Ferreira
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: ADO RDD xHarbour
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
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
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: ADO RDD xHarbour
Antonio,
EMG
Using adUseClient the performance is better than adUseServer!AHF wrote:If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot.
EMG
Re: ADO RDD xHarbour
Enrico,
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.
Please note that the I'm using SELECT * FROM ... in adordd thats its really not good SQL practice but compatibility much be achieved.
What DB you use?Enrico Maria Giordano wrote:Antonio,
Using adUseClient the performance is better than adUseServer!AHF wrote:If we use always adUseClient because ADO knows all rows and there ist any problem but performance decreases a lot.
EMG
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.
Please note that the I'm using SELECT * FROM ... in adordd thats its really not good SQL practice but compatibility much be achieved.
Regards
Antonio H Ferreira
Antonio H Ferreira
Re: ADO RDD xHarbour
Antonio,
One with normal index the RECORDCOUNT = nr of records dbf = ORDKEYCOUNT
Second with conditional index SELECT WHERE ... the RECORDCOUNT = nr of records dbf <> ORDKEYCOUNT that is = nr of records within the WHERE clause.
Moving through the recordset will soon or later get an error.
Please note that the recordset has in fact only the records within the condition although RECORDCOUNT reports all records.
This is using serverside cursor.
Opening same dbf in 2 dif areasAntonio 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
One with normal index the RECORDCOUNT = nr of records dbf = ORDKEYCOUNT
Second with conditional index SELECT WHERE ... the RECORDCOUNT = nr of records dbf <> ORDKEYCOUNT that is = nr of records within the WHERE clause.
Moving through the recordset will soon or later get an error.
Please note that the recordset has in fact only the records within the condition although RECORDCOUNT reports all records.
This is using serverside cursor.
Regards
Antonio H Ferreira
Antonio H Ferreira
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: ADO RDD xHarbour
Antonio,
SELECT * FROM is the base of all SQL queries. What else would you want to use?
EMG
MDB, MSSQL and MySQL.AHF wrote:What DB you use?
adUseClient is faster in my experience.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.
SELECT * FROM is the base of all SQL queries. What else would you want to use?
EMG
Re: ADO RDD xHarbour
I mean avoid loading all the fields instead of just the ones we need for the task.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
Regards
Antonio H Ferreira
Antonio H Ferreira
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: ADO RDD xHarbour
Antonio
EMG
Ok, but what if I need all the fields?AHF wrote:I mean avoid loading all the fields instead of just the ones we need for the task.
EMG
Re: ADO RDD xHarbour
Then SELECT colname FROM table unfortunatly in adordd its always all the fields! Its the price for no code change.Enrico Maria Giordano wrote:Antonio
Ok, but what if I need all the fields?AHF wrote:I mean avoid loading all the fields instead of just the ones we need for the task.
EMG
Regards
Antonio H Ferreira
Antonio H Ferreira
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: ADO RDD xHarbour
Antonio,
EMG
Ok, I see, you're right.AHF wrote:Then SELECT colname FROM table unfortunatly in adordd its always all the fields! Its the price for no code change.
EMG
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: ADO RDD xHarbour
Do you mean DbCloseAll() ?
I think you have to implement UR_CLOSE
I think you have to implement UR_CLOSE