🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with parameters and date fields

#1305
From: Viatcheslav V. Vassiliev
Date: Mon, 09 Aug 2004 10:33
54 lines
2499 bytes
ADO Express converts :param into ?, so query you pass to server is:

SELECT COUNT(*) AS TOTAL FROM SCHEMAS WHERE
 DATAARR < ? AND DATAPAR >= ?

As you could see, there is 2 parameters. Use query SQL Server style
parameters (@param, with DECLARE), or pass 2 parameters with the same value.

//------------------------------------------
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)

"Francesco" <.> ???????/???????? ? ???????? ?????????:
news:41174df9@newsgroups.borland.com...
>
> Ohhps I forgot, I use MSDE 2000 with BCB 5.
>
>
> >
> > Hello,
> >
> > I've a problem, a simple query like the follow give me the wrong
> > result TOTAL=0
> >
> >
> > ADOQuery1->Close();
> > ADOQuery1->SQL->Clear();
> > ADOQuery1->SQL->Add("SELECT COUNT(*) AS TOTAL FROM SCHEMAS WHERE
> > DATAARR < :data1 AND DATAPAR >= :data1");
> > ADOQuery1->Parameters->ParamByName("data1")->Value =
> > StrToDate("13/08/2004");
> > ADOQuery1->Open();
> >
> >
> > if I do the same query but in this way, I've the correct result
> > TOTAL=1
> >
> >
> > SELECT COUNT(*) AS TOTAL
> > FROM SCHEMAS
> > WHERE DATAARR < CAST('13/08/2004' AS DATETIME)
> > AND DATAPAR >= CAST ('13/08/2004' AS DATETIME)
> >
> >
> > Is there any know problem using parameters with date fields, both
> > fields DATAARR AND DATAPAR are defined as datetime (8).
> >
> >
> > thanks, Francesco
>
Technical Details
Message-ID: <41175306@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <41174ae2@newsgroups.borland.com> <41174df9@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,33d4f63ac70a410f
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <41174ae2@newsgroups.borland.com> <41174df9@newsgroups.borland.com>
Subject: Re: Problem with parameters and date fields
Date: Mon, 9 Aug 2004 14:33:37 +0400
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 213.234.218.42
Message-ID: <41175306@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1092047622 213.234.218.42 (9 Aug 2004 03:33:42 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail