🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Using a parameter multiple times

#1894
From: Viatcheslav V. Vassiliev
Date: Tue, 13 Jan 2004 15:45
61 lines
2902 bytes
ADO components replace :ParamName with ? in actual query. Try Access
specific syntax:

Parameters SDate DateTime, EDate DateTime;
 SELECT
    a.[Name],
    a.[StartDate],
    a.[EndDate],
    a.[Hours],
    (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= SDate AND
 b.[EndDate] <= EDate) AS Total
 FROM [ATable] AS a
 WHERE a.[StartDate] >= SDate AND a.[EndDate] <= EDate ;

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

"Freshy" <_REMOVE_THIS_freshy_s@hotmail.com> �������/�������� � ��������
���������: news:40034ae2$1@newsgroups.borland.com...
> Hello,
>
> I have a query to run against an Access 2000 database for a report where I
> need to use a parameter twice.  For example:
>
> SELECT
>    a.[Name],
>    a.[StartDate],
>    a.[EndDate],
>    a.[Hours],
>    (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= :SDate
AND
> b.[EndDate] <= :EDate) AS Total
> FROM [ATable] AS a
> WHERE a.[StartDate] >= :SDate AND a.[EndDate] <= :EDate ;
>
> I know that ADO has a problem with this, so I tried a couple of
variations:
>
> SELECT
>    a.[Name],
>    a.[StartDate],
>    a.[EndDate],
>    a.[Hours],
>    :SDate AS PSDate,
>    :EDate AS PEDate,
>    (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= PSDate
AND
> b.[EndDate] <= PEDate) AS Total
> FROM [ATable] AS a
> WHERE a.[StartDate] >= PSDate AND a.[EndDate] <= PEDate ;
>
> Unfortunately, this did not work.  Does anyone know of a way around this?
>
> Thanks,
> Ken
>
>
Technical Details
Message-ID: <4004128a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!newsfeeds.sol.net!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40034ae2$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,1641a77b6273a1af
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-01-13 08:09:58 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <40034ae2$1@newsgroups.borland.com>
Subject: Re: Using a parameter multiple times
Date: Tue, 13 Jan 2004 18:45:05 +0300
Lines: 63
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: <4004128a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1074008714 213.234.218.42 (13 Jan 2004 07:45:14 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!newsfeeds.sol.net!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail