🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TADOQuery Stupid Question ParamByName vs SQL Text

#676
From: Arnie
Date: Wed, 22 Feb 2006 14:56
84 lines
3453 bytes
"Heinz Ketchup" 
<heinz_like_the_ketchup@h0tmail.n0spam.c0m.n0spam> wrote in 
message news:43fb7f38$1@newsgroups.borland.com...
>
> I Apologize if this is a stupid question, but I haven't had
> any success thus far on resolving this issue.
>
> I have a TADO query setup at design time with a SQL Statement
> and Parameters.
>
> When I assign the Parameters based on the design time query
> everything works peachy clean.
>
> // Perform SQL Operations
> QueryPointer->Close();
>
> QueryPointer->Parameters->ParamByName("StartDateTimeString")->Value 
> = StartingDateTime;
>
> QueryPointer->Parameters->ParamByName("EndDateTimeString")->Value 
> = EndingDateTime;
>
> QueryPointer->Parameters->ParamByName("TagNameQuery")->Value = 
> TagNameString;
>
> QueryPointer->Open();
>
> Do stuff with the dataset.
>
> The SQL Statement is
> SELECT tagName, timeString, curVal, offset
> FROM DBA.vwAccumMinute
> WHERE (tme >= :StartDateTimeString) AND (tme <= 
> :EndDateTimeString) AND (tagName = :TagNameQuery)
> ORDER BY tme
>
> On the Down Side:
> When I manually create the SQL Text:
> The error I get is a type mismatch.
>
> QueryPointer->Close();
> QueryPointer->SQL->Clear();
> QueryPointer->SQL->Text = SQLStatementString;
> QueryPointer->Open();
>
> ...
> SQLStatementString =
> "SELECT tagName, timeString, curVal, offset
> FROM DBA.vwAccumMinute
> WHERE (tme >= '1138778100' AND tme <= '1138863600') AND 
> (tagName = 'Tag1') ORDER BY tme
>
> On the analysis of both SQL Statement's, they appear identical.
> The process I use is just a little different.
>
> The reason I am doing this is to see if I can use the same 
> Query with a "modified" sql statement.
> i.e. SELECT tagName, timeString, curVal
> blah blah blah...
> WHERE (tagName = 'This' or tagName = 'That' or tagName = 
> 'Meep')
>
> Any assistance is HIGHLY appreciated.
> PS: Code is in the correct order and compiles fine.
> I'm just trying to get across my problem, so please don't take
> the represented code line by line.
>
> Thank you v. much,
> Heinz

Hi Heinz,

My guess is that the problem is in:

WHERE (tme >= '1138778100' AND tme <= '1138863600') AND (tagName 
= 'Tag1') ORDER BY tme

Those numbers don't look like any valid date/time format to me. 
I'd suggest using parameters as you did with the design-time SQL 
statement.  In fact, I suggest you always use parameters for best 
efficiency and to make sure you don't have to escape quote 
characters out of literal strings.

- Arnie 
Technical Details
Message-ID: <43fc7b6a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <43fb7f38$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,6c24e68800b2d06
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Arnie" <none>
Newsgroups: borland.public.cppbuilder.database.ado
References: <43fb7f38$1@newsgroups.borland.com>
Subject: Re: TADOQuery Stupid Question ParamByName vs SQL Text
Date: Wed, 22 Feb 2006 09:56:16 -0500
Lines: 86
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 12.29.236.34
Message-ID: <43fc7b6a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1140620138 12.29.236.34 (22 Feb 2006 06:55:38 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail