🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Flexible SQL Queries through ADO.

#1615
From: Viatcheslav V. Vassiliev
Date: Wed, 02 Jun 2004 06:49
82 lines
3557 bytes
SELECT ?, ?

Most (if not all) DBMS will not allow parameters at this place. Enclose also
column names into quotes - Date is probably keyword. Use TADODataSet and set
CommandText property.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Heinz Ketchup" <heinz_like_the_ketchup@h0tmail.no_spam.c0m.no_spam>
�������/�������� � �������� ���������:
news:40bb4d03$1@newsgroups.borland.com...
>
> Thanks Mark,
>
> The first method works fine for me.
>
> Although I did try your second method, and it didn't seem to work.
> Is there something special that changes in the SQL Query?
>
> i.e.
> C++ Code
> DynamicFlexSQLStmt = "SELECT :Var1, :Var2 ";
> DynamicFlexSQLStmt += "FROM mySQLTable ";
> DynamicFlexSQLStmt += "WHERE Date >= :StartDate ";
> DynamicFlexSQLStmt += "AND Date <= :EndDate ";
>
> TADOQuery1->Parameters->ParseSQL(DynamicFlexSQLStmt, true);
> TADOQuery1->Parameters->ParamByName("Var1")->Value = "Date";
> etc...
>
> Debugging the DynamicFlexSQLStmt
> DynamicFlexSQLStmt = "SELECT ?, ? FROM mySQLTable WHERE Date >= ? AND Date
<= ?"
> It starts when the ParseSQL statement command is executed,
> and remains that way after all the ParamByName statements are called
>
> I get an error "No Value given for one or more required Parameters"
>
> Any thoughts?
> And THANKS A LOT for the your reply!
> You've helped a whole heaps load!
>
> Heinz.
>
>
>
> "Mark Guerrieri" <markg11@comcast.net> wrote:
> >>
> >> AnsiString DynamicFlexSQLStmt = "SELECT Date " + ""... (Whatever I add
for
> >Column Selections)
> >>
> >> I cannont use TADOQuery1->SQL->Add(":MyFlexibleSQLStmt");
> >> TADOQuery1->SQL->Parameters->ParamByName("MyFlexibleSQLStmt")->Value =
> >DynamicFlexSQLStmt;
> >>
> >
> >Try this-
> >
> >AnsiString DynamicFlexSQLStmt = "SELECT Date " + ""... (Whatever I add
for
> >Column Selections)
> >TADOQuery1->SQL->Text = DynamicFlexSQLStmt;
> >
> >I do this all the time and it works fine.  I don't bother with
parameters,
> >I just build the values right into the SQL statement.  If you need
> >parameters, add this:
> >
> >TADOQuery1->Parameters->ParseSQL(DynamicFlexSQLStmt, true);
> >TADOQuery1->Parameters->ParamByName("ParamName")->Value = ParamValue;
> >
> >Mark
> >
> >
>
Technical Details
Message-ID: <40bd7880@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40ba50b3$1@newsgroups.borland.com> <40baa32b$1@newsgroups.borland.com> <40bb4d03$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,88aab88ffc95b09
X-Google-Attributes: gid10698b,public
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <40ba50b3$1@newsgroups.borland.com> <40baa32b$1@newsgroups.borland.com> <40bb4d03$1@newsgroups.borland.com>
Subject: Re: Flexible SQL Queries through ADO.
Date: Wed, 2 Jun 2004 10:49:42 +0400
Lines: 84
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 213.234.218.42
Message-ID: <40bd7880@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1086158976 213.234.218.42 (1 Jun 2004 23:49:36 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail