Delphi IDE (89)
Windows with Delphi (280)
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:
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.
You don't like the formatting? Check out SourceCoder then!
MyArr := ..
case FieldCount of
0: 1: found := Table1.Locate(FieldStr, MyArr, );
else found := Table1.Locate(FieldStr, MyArr, );