Article View: borland.public.cppbuilder.database.ado
Article #5110Re: problem with (probably) ExecSQL during loop insertion
From: Peter Falconer
Date: Fri, 13 Jul 2001 22:13
Date: Fri, 13 Jul 2001 22:13
36 lines
2165 bytes
2165 bytes
G'day Guy,
I think you need to close the query before changing the parameter the
second and subsequent iterations. Also you could move the
Form1->TADOQuery1->SQL->Clear();
Form1->TADOQuery1->SQL->Add("insert into Table1 values
...
out of the loop.
Guy wrote in message <3b4efb1d_1@dnews>...
>Hi, I tried to write a function that reads some data from a
TStringList
>Object and inserts it to DB Table dynamicly using a loop.
>This is our source code: (
>
> TStringList *Labels=new TStringList;
> Labels->LoadFromFile("Labels.txt");
> Form1->TADOQuery1->Parameters->ParamByName("v_Name")->Value =
Name;
>
> for (int i=0; i<Labels->Count; i++)
> {
> String Label=Labels->Strings[i];
>
Form1->TADOQuery1->Parameters->ParamByName("v_Label")->Value
>= Label;
> Form1->TADOQuery1->SQL->Clear();
> Form1->TADOQuery1->SQL->Add("insert into Table1
values
>(:v_Name, :v_Label)");
> Form1->TADOQuery1->ExecSQL();
> }
>
>
>It works propertly only in the first iteration. Then (during the
second
>iteration) it stucks on the ExecSQL line.
Technical Details
Message-ID:
<3b4f71cc$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3b4efb1d_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,8147153c2309c21b X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-07-13 15:14:23 PST From: "Peter Falconer" <Peter.Falconer@fsunion.org.au> Newsgroups: borland.public.cppbuilder.database.ado References: <3b4efb1d_1@dnews> Subject: Re: problem with (probably) ExecSQL during loop insertion Date: Sat, 14 Jul 2001 08:13:10 +1000 Lines: 38 Organization: FSU MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 NNTP-Posting-Host: 203.55.24.2 Message-ID: <3b4f71cc$1_2@dnews> X-Trace: dnews 995062220 203.55.24.2 (13 Jul 2001 15:10:20 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews