Article View: borland.public.cppbuilder.database.ado
Article #4451Re: Params and ADOQuery
From: David Barnes
Date: Wed, 02 Jan 2002 15:35
Date: Wed, 02 Jan 2002 15:35
43 lines
2473 bytes
2473 bytes
From what I see of this code, I would remove the single quotes from your
Select statement. Ex.
> ADOQuery3->SQL->Add(":ACode AS expr1,");
I believe you only need these when you have text in your SQL. Ex.
> ADOQuery3->SQL->Add("where Author_Name = 'TOLKIEN' ");
and then as a qualifier, not as a field name.
Do you not know what field names you will be using when running your query?
Maybe what you are looking for would be more like this:
ADOQuery3->SQL->Add( "INSERT INTO Author ( Author_Code, Author_Name,
Author_Address ) " );
ADOQuery3->SQL->Add( "SELECT NewCode, NewName, NewAddress FROM NewTable
where NewName = :AName " );
ADOQuery3->Query3->Parameters->ParamByName( "AName" )->Value = "TOLKIEN";
etc...
Hope this is more helpful then confusing.
David Barnes
Marshall wrote:
> Just to clarify a bit:
>
> ADOQuery3->SQL->Add("INSERT INTO Author(Author_Code, Author_Name,
> Author_Address) SELECT ");
> ADOQuery3->SQL->Add("' :ACode ' AS expr1,");
> ADOQuery3->SQL->Add("' :AName ' AS expr2,");
> ADOQuery3->SQL->Add("' :AAddress ' AS expr3;");
>
> ADOQuery3->Parameters->ParamByName("ACode")->Value = ACode;
> ADOQuery3->Parameters->ParamByName("AName")->Value = AName;
> ADOQuery3->Parameters->ParamByName("AAddress")->Value = AAddr;
>
> is the code im using and the error i get is:
>
> <Project Name.exe> raised exception class EDatabaseError with message
> 'Parameter 'ACode' not found'.
Technical Details
Message-ID:
<3C3328DC.5030202@kalos-inc.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!195.64.68.27!newsgate.cistron.nl!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3c32b114_2@dnews> <3c32b92d_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,4aff3e15a2c4b841 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-01-02 07:41:05 PST Message-ID: <3C3328DC.5030202@kalos-inc.com> Date: Wed, 02 Jan 2002 09:35:56 -0600 From: David Barnes <david@kalos-inc.com> User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Params and ADOQuery References: <3c32b114_2@dnews> <3c32b92d_2@dnews> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 65.69.231.139 X-Trace: dnews 1009985757 65.69.231.139 (2 Jan 2002 07:35:57 -0800) Lines: 44 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!195.64.68.27!newsgate.cistron.nl!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews