Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Call to ADTable->Locate compiles but crashes on execution


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Sep 11, 2017 4:58 PM Last Post By: charles leggette
charles leggette

Posts: 45
Registered: 7/17/00
Call to ADTable->Locate compiles but crashes on execution  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 10:04 AM
THIS WAS ORIGINALLY POSTED TO HE WRONG FORUM.

I used to use Locate(...) in my pre-widestring apps......now the following code returns an error
TLocateOptions Opts;
Opts.Clear();
unsigned short bFound = false;
Variant locvalues[2];
locvalues[0] = Variant(s);// s and pn are valid strings present in database and LOGINNAME is a valid Index.
locvalues[1] = Variant(pn);
if (AdoTable->Locate("LOGINNAME", VarArrayOf(locvalues, 1), Opts))
{
return(true);
}

ERROR>>>>EVariantTypeCastError-- could not convert variant of type (Array Variant)into type (OleStr);

Anyone have a clue as to how to use locate in a TADOTable context?
charles leggette

Posts: 45
Registered: 7/17/00
Re: Call to ADTable->Locate compiles but crashes on execution  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 4:58 PM   in response to: charles leggette in response to: charles leggette
charles leggette wrote:
THIS WAS ORIGINALLY POSTED TO HE WRONG FORUM.

I used to use Locate(...) in my pre-widestring apps......now the following code returns an error
TLocateOptions Opts;
Opts.Clear();
unsigned short bFound = false;
Variant locvalues[2];
locvalues[0] = Variant(s);// s and pn are valid strings present in database and LOGINNAME is a valid Index.
locvalues[1] = Variant(pn);
if (AdoTable->Locate("LOGINNAME", VarArrayOf(locvalues, 1), Opts))
{
return(true);
}

ERROR>>>>EVariantTypeCastError-- could not convert variant of type (Array Variant)into type (OleStr);

When using Locate(...), the first argument is a bit like the Filter= args, it is not the name of the Index, it is the Index Fields, so instead of using LOGINNAME, using the fields that make up the index , e.g., USERNAME;PASSWORD works perfectly.

Anyone have a clue as to how to use locate in a TADOTable context?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02