🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3227

Re: Locate and VarArrayCreate

#3227
From: Kim Utley
Date: Mon, 28 Oct 2002 14:32
86 lines
3275 bytes
Mark,

When I use the TVariant (TVariant vKey[1]) I get an exception "Arguments are
of the wrong type, are out of acceptable range, or are in conflict with one
another".

If I use (Variant vKey[1]) no exception and appears to fetch the correct
record.

IAE, thanks for your help.

Kim


"Mark Guerrieri" <markg11@comcast.net> wrote in message
news:3dbc6d21$1@newsgroups.borland.com...
> 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: <3dbd4a66$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3db98cbe@newsgroups.borland.com> <3dbac521@newsgroups.borland.com> <3dbc6d21$1@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-28 08:36:02 PST
From: "Kim Utley" <kim@simsware.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3db98cbe@newsgroups.borland.com> <3dbac521@newsgroups.borland.com> <3dbc6d21$1@newsgroups.borland.com>
Subject: Re: Locate and VarArrayCreate
Date: Mon, 28 Oct 2002 08:32:11 -0600
Lines: 88
Organization: SIMS, Inc.
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: 65.205.74.136
Message-ID: <3dbd4a66$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1035815526 65.205.74.136 (28 Oct 2002 06:32:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail