This site is temporarily down. Please come back. Locate() fails with 'Variant conversion error'
DelphiFAQ Home Search:

Locate() fails with 'Variant conversion error'


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

  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!
Content-type: text/html




NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: