fprovin
asked on
Findkey doesn't work with TClientDataSet - TDataSetProvider - TAdoTable
Hi,
I have a access table with a filed primarykey (string file)
Last month i put a form in delphi to use this table with :
1°) Tadoconnection (i tried cursorlocation with clUseClient - and cluseserver aind i tried connectionstring based on Microsoft ole db provider for odbc driver and microsoft jet 4.0 old db provider)
2°) TAdotable (cursorlocation = clUserServer, Locktype = ltBatchOptimistic, Tabledirect = True) based on Tadoconnection
3°) TDataSetProvider based on TAdotable
4°) TClientDataSet (i tried with IndexFieldNames and without IndexFieldNames) based on TDataSetProvider
==> TClientDataSet.FindKey(['V alue']) was OK
I re-do this form this week and TClientDataSet.FindKey(['V alue']) not work (don't find the record).
The acces table has no change between this. I believe it's in the parameter of my components but i don't find where.
Other possibility : i d'ont remenber if last month i create the connection string in delphi conception or if i used a .udl filed : but normally there are no difference.
Thanks for your answer
I have a access table with a filed primarykey (string file)
Last month i put a form in delphi to use this table with :
1°) Tadoconnection (i tried cursorlocation with clUseClient - and cluseserver aind i tried connectionstring based on Microsoft ole db provider for odbc driver and microsoft jet 4.0 old db provider)
2°) TAdotable (cursorlocation = clUserServer, Locktype = ltBatchOptimistic, Tabledirect = True) based on Tadoconnection
3°) TDataSetProvider based on TAdotable
4°) TClientDataSet (i tried with IndexFieldNames and without IndexFieldNames) based on TDataSetProvider
==> TClientDataSet.FindKey(['V
I re-do this form this week and TClientDataSet.FindKey(['V
The acces table has no change between this. I believe it's in the parameter of my components but i don't find where.
Other possibility : i d'ont remenber if last month i create the connection string in delphi conception or if i used a .udl filed : but normally there are no difference.
Thanks for your answer
Read this article about Locate and FindKey
http://edn.embarcadero.com/article/29176
http://edn.embarcadero.com/article/29176
ASKER
Hi ewangoya,
Thanks but i tried this and it's not work too (return of findkey : False).
I agree that for this table i may use locate because it's a small table but i have the same problem with a big table (more than 100 000 records and it's going up) and i am afraid about locate performance when i will arrive at 500 000 records or more...
Best regards
Thanks but i tried this and it's not work too (return of findkey : False).
I agree that for this table i may use locate because it's a small table but i have the same problem with a big table (more than 100 000 records and it's going up) and i am afraid about locate performance when i will arrive at 500 000 records or more...
Best regards
if the clientdataset is indexed, Locate will use the index. However if there are no appropriate indexes, then it resorts to scanning the dataset one record at a time, this is when you loose alot of performance
ASKER
I 'am ok with you but if findkey does'nt work it's probably because it doesnt use the index ? and if yes locate will do the same thing ?
And i don't understand why findkey doesn't work.
Best regards
And i don't understand why findkey doesn't work.
Best regards
ASKER
Hi,
In the zip there are my delphi source and the access data base
Three comments :
1°) i add a ".txt" extension on many source file to have the possibilitie to send the zip here.
2°) When you open the sources you had to activate the TClientDataSet (unit and form 7).
3°) Depends on your path you will have to change the connection string on the tadoconnection (unit and form 8)
When you clic on the "button 2" you have first a try with findkey and second with locate.
If you look step by step the findkey doesn't work.
Best regards
TestFindkey.zip
In the zip there are my delphi source and the access data base
Three comments :
1°) i add a ".txt" extension on many source file to have the possibilitie to send the zip here.
2°) When you open the sources you had to activate the TClientDataSet (unit and form 7).
3°) Depends on your path you will have to change the connection string on the tadoconnection (unit and form 8)
When you clic on the "button 2" you have first a try with findkey and second with locate.
If you look step by step the findkey doesn't work.
Best regards
TestFindkey.zip
Here is your error, b is in lower case
DataModule7.clientdataset1 .IndexFiel dNames := 'NomVariable';
if (DataModule7.clientdataset 1.FindKey( ['bGestion Fraisbours iers'])) then
begin
{coucou}
stest := 'Ok' ;
end ;
bGestionFrais b oursiers //b is in lowercase so the word is not found
check if your index is case sensitive
DataModule7.clientdataset1
if (DataModule7.clientdataset
begin
{coucou}
stest := 'Ok' ;
end ;
bGestionFrais b oursiers //b is in lowercase so the word is not found
check if your index is case sensitive
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Diagnostic OK
Solutions for the problem and more .
Very goog
Thanks
Solutions for the problem and more .
Very goog
Thanks
Clientdataset1.IndexFieldN
Clientdataset1.FindKey([Ed