Subject | Strange thing with Locate() |
---|---|
Author | Dany Marmur |
Post date | 2002-11-03T12:31Z |
Hi!
This might be a Delphi issue but here I go; look at this simple App;
procedure TForm1.FormCreate(Sender: TObject);
var
AValues: array of string;
begin
IB_Query1.Open;
if (IB_Query1.Locate('INTEGER_ID', '67', [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
if (IB_Query1.Locate('INTEGER_ID', '', [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
SetLength(AValues, 1);
AValues[0] := '67';
if (IB_Query1.Locate('INTEGER_ID', AValues, [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
{ The place referred to below }
AValues[0] := '';
if (IB_Query1.Locate('INTEGER_ID', AValues, [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
end;
Works like a charm down to the place referred to where I get an exception
EVariantTypeCastError with message 'Could not convert variant of type
(OleStr) into type (Double)'.
I might not have thought it was strange since the column is a INTEGER type
(not null) but it works if I pass onle _single_ string (not an array), and
it works if the array item at 0 contains something. Also the same code with
AValues: array of variant; gives the same error.
If this in deed is a delphi issue - don't bother to anser.
Thanks!
/Dany
This might be a Delphi issue but here I go; look at this simple App;
procedure TForm1.FormCreate(Sender: TObject);
var
AValues: array of string;
begin
IB_Query1.Open;
if (IB_Query1.Locate('INTEGER_ID', '67', [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
if (IB_Query1.Locate('INTEGER_ID', '', [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
SetLength(AValues, 1);
AValues[0] := '67';
if (IB_Query1.Locate('INTEGER_ID', AValues, [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
{ The place referred to below }
AValues[0] := '';
if (IB_Query1.Locate('INTEGER_ID', AValues, [])) then
Application.MessageBox('Found', 'Yo!', 0)
else
Application.MessageBox('Did not find', 'Yo!', 0);
end;
Works like a charm down to the place referred to where I get an exception
EVariantTypeCastError with message 'Could not convert variant of type
(OleStr) into type (Double)'.
I might not have thought it was strange since the column is a INTEGER type
(not null) but it works if I pass onle _single_ string (not an array), and
it works if the array item at 0 contains something. Also the same code with
AValues: array of variant; gives the same error.
If this in deed is a delphi issue - don't bother to anser.
Thanks!
/Dany