When searching a TADODataSet with Locate on a single field, if the
field contains
no data and TLocateOptions is set to loPartialKey the following error
is raised:
'EDataBase error with message: TADODataSet record not found'. At this
time
the parameters Fields and KeyFields (see GetFieldList(Fields,
KeyFields) in
the LocateRecord methode in AdodB.pas) contains respectively "nil" and
'Ado Recordset'.
I perform the search in the AfterScroll event of the DataSet. I search
for a DRAWING
NUMBER if it is not found I search for a DESCRIPTION. If there is no
Drawing number for the record the error occured.
procedure TDMod.ADOSetPACKING_REF_R4AfterScroll(DataSet: TDataSet);
var
SearchOptions: TLocateOptions;
begin
if not loFromPackingCreator then
begin
// SearchOptions := [loPartialKey];
if not ADOSetPROJ_REF_R4.Locate('DRAWING_NO',
ADOSetPACKING_REF_R4DRAWING_NO.Value,
SearchOptions) then
ADOSetPROJ_REF_R4.Locate('DESCRIP',
ADOSetPACKING_REF_R4DESCRIP.Value,
SearchOptions);
end;
end;
end;
Thank you for your time
Serge Myrand
When the first Locate fails and TLOcateOptions <> [loPartialKey] ) I do
not get the error message but the cursor steps at the end of the procedure
(event) and the second Locate is not executed, if I put a Try Except block,
the second Locate is execute but it always fails event if the corresponding
value exists in the searched table for that field. After the first Locate
has failed, ADODataSet.First does not move the cursor to the First record.
Am'I doing something wrong?
Thank you very much for your time
Serge Myrand
if EdtSearch.Text = '' then
AdoTable1.First
else
AdoTable.Locate('FieldA', EdtSearch.Text, [loPartialKey]);
It ain't pretty but I had to get something up.
--
J. M. "Papa Joe" De Moor
www.objectpac.com
Serge Myrand <in...@softdelirium.qc.ca> wrote in message
news:382ABC62...@softdelirium.qc.ca...
Thanks
Serge Myrand
> When searching a TADODataSet with Locate on a single field, if the
> field contains
> no data and TLocateOptions is set to loPartialKey the following error
> is raised:
> 'EDataBase error with message: TADODataSet record not found'. At this
> time
> the parameters Fields and KeyFields (see GetFieldList(Fields,
> KeyFields) in
> the LocateRecord methode in AdodB.pas) contains respectively "nil" and
> 'Ado Recordset'.
Can you give me a little more information on this? In the case where you are
getting the error what is being passed for the second parameter to Locate (the
values) is it Null or an empty string? Also, can you tell me which line of code
is actually raising the "record not found" exception? If you can give me more
specific steps on how to reproduce the error I'd like to track this down.
Mark
Here are the answers, the Locate is written as follow;
try
loFound := ADOSetPROJ_REF_R4.Locate('DRAWING_NO',
ADOSetPACKING_REF_R4DRAWING_NO.Value,
SearchOptions); // loPartialKey, loCaseInsensitive
except
.......
.......
end;
When the field is empty the value of the second parameter is an EmptyString
The program fails on the GetFieldList(Fields, KeyFields) in ADDB.pas
This morning to answer your questions I put my routine as it was and I got the
error message: "The application is using arguments that are the wrong type, are out
of acceptable range or are in conflict with one other"
My routine is called in the AfterScrool event of a DataSet an search in another
DataSet.
Hope this will help, thank you again
Serge Myrand
> This morning to answer your questions I put my routine as it was and I got
the
> error message: "The application is using arguments that are the wrong type, are
out
> of acceptable range or are in conflict with one other"
Sorry this has taken me so long to get back to you. When loPartialKey is
specified and the search string is blank (not null), then the filter expression
used to find the value is not constructed correctly. There is a fix to the VCL
which will prevent the error, but even with the fix the locate will still fail.
You should test for the empty string and instead pass a Null value.
Mark