Delphi .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Locate() fails with 'Variant conversion error'
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Locate() fails with a 'Variant conversion error', if you search for only one field and have this in a variant array.
This is a problem if you create the array to search for dynamically at runtime.
In the case, that you array would have only one entry, you have to pass the value itself:
Note:
This was observed under Delphi 3 with BDE 5 using InterBase and MS-SQL. I don't know if the problem occurs with later versions of Delphi. BDE version and dbms should not matter.
 | |  | | begin
..
MyArr := ..
FieldStr :=
..
case FieldCount of
0: 1: found := Table1.Locate(FieldStr, MyArr[0], []);
else found := Table1.Locate(FieldStr, MyArr, []);
end;
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|