DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Locate() fails with 'Variant conversion error'

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.

   MyArr := ..
   FieldStr := 
   case FieldCount of
   0: // error
   1:   found := Table1.Locate(FieldStr, MyArr[0], []);
   else found := Table1.Locate(FieldStr, MyArr, []);
You don't like the formatting? Check out SourceCoder then!
Generated 0:01:27 on Nov 21, 2017