Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TADODataSet Locate

145 views
Skip to first unread message

Serge Myrand

unread,
Nov 10, 1999, 3:00:00 AM11/10/99
to
Hi,

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


Serge Myrand

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to
Hi,

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


J. M. De Moor

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to
I had the same problem so I put a kind of awkward trap, e.g.,

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...

Serge Myrand

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to
"Papa Joe",
Yes you are right, I did the same thing than you.

Thanks
Serge Myrand

Mark Edington (Borland)

unread,
Nov 17, 1999, 3:00:00 AM11/17/99
to
Serge Myrand <in...@softdelirium.qc.ca> wrote in message
news:3829FA2B...@softdelirium.qc.ca...

> 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

Serge Myrand

unread,
Nov 20, 1999, 3:00:00 AM11/20/99
to
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

Mark Edington (Borland)

unread,
Dec 6, 1999, 3:00:00 AM12/6/99
to
Serge Myrand <in...@softdelirium.qc.ca> wrote in message
news:3836CD5B...@softdelirium.qc.ca...

> 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


Serge Myrand

unread,
Dec 10, 1999, 3:00:00 AM12/10/99
to
That's Ok Thank you again
Serge Myrand
0 new messages