Article View: borland.public.cppbuilder.database.ado
Article #3224Re: Locate and VarArrayCreate
From: Mark Guerrieri
Date: Sun, 27 Oct 2002 22:48
Date: Sun, 27 Oct 2002 22:48
63 lines
2908 bytes
2908 bytes
There is only one method. The key value is being cast to a single element
Variant array internally. Since there is only one key field, only the first
element is being accessed, so all is ok. For consistancy, you could code it
as follows:
TLocateOptions options;
TVariant vKeys[1];
vKeys[0] = "KeyValue";
TADOTable->Locate( "FieldName", vKeys, options );
If you need more than one key field, increase the array size and assign the
indicies accordingly.
Mark
"Kim L. Utley" <kimutley@coserv.net> wrote in message
news:3dbac521@newsgroups.borland.com...
> Hello,
>
> I figured out that when calling Locate() using a single key field you
should
> not create a Variant for the key value but simply pass the value itself
> (e.g., TADOTable->Locate( "FieldName", "KeyValue", options ); ). However,
I
> would like to not have separate methods of calling Locate() depending on
the
> number of field names. Is there a way to accomplish this?
>
> TIA,
>
> Kim
>
> > Hello,
> >
> > I'm getting an exception "Could not convert variant of type (Array
> Variant)
> > in type (String)" when the Locate() function is called. In my
application
> I
> > need to dynamically create the field name(s) and key value(s) although
in
> my
> > example I'm hard coding the data for testing. Most of the time they will
> be
> > strings but other data types will need to be used.
> >
> > Any help would be appreciated.
> >
> > TIA,
> >
> > Kim
> >
> > int bounds[2] = { 0, 1 };
> > Variant keyVal = VarArrayCreate( bounds, 1, varVariant);
> >
> > keyVal.PutElement( "01-01-0002", 0 );
> >
> > bool success = adoTable->Locate( "AccountNumber", keyVal, opts );
> >
> >
>
>
Technical Details
Message-ID:
<3dbc6d21$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!newsfeed.news2me.com!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3db98cbe@newsgroups.borland.com> <3dbac521@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,880f9a9f70573d4a X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-10-27 14:54:13 PST From: "Mark Guerrieri" <markg11@comcast.net> Newsgroups: borland.public.cppbuilder.database.ado References: <3db98cbe@newsgroups.borland.com> <3dbac521@newsgroups.borland.com> Subject: Re: Locate and VarArrayCreate Date: Sun, 27 Oct 2002 17:48:09 -0500 Lines: 65 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 68.44.67.205 Message-ID: <3dbc6d21$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1035758881 68.44.67.205 (27 Oct 2002 14:48:01 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!newsfeed.news2me.com!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail