Article View: borland.public.cppbuilder.database.ado
Article #1306Re: Problem with parameters and date fields
From: Giuliano
Date: Mon, 09 Aug 2004 10:34
Date: Mon, 09 Aug 2004 10:34
46 lines
2078 bytes
2078 bytes
On 9 Aug 2004 02:58:58 -0700, "Francesco" <.> wrote:
>
>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).
>
>
Ciao Francesco
prova con qualcosa del genere:
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT COUNT(*) AS TOTAL FROM SCHEMAS WHERE
DATAARR < :data1_1 AND DATAPAR >= :data1_2");
ADOQuery1->Parameters->ParamByName("data1_1")->Value =
StrToDate("13/08/2004");
ADOQuery1->Parameters->ParamByName("data1_2")->Value =
StrToDate("13/08/2004");
ADOQuery1->Open();
Giuliano
Technical Details
Message-ID:
<sjkeh0ti63ibdg8ve16bakr3i6qmbsqh5j@4ax.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-mailReferences:
<41174ae2@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: Giuliano <gcardinali@remove.adhoc.net> Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Problem with parameters and date fields Date: Mon, 09 Aug 2004 12:34:24 +0200 Message-ID: <sjkeh0ti63ibdg8ve16bakr3i6qmbsqh5j@4ax.com> References: <41174ae2@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.72.236.131 X-Trace: newsgroups.borland.com 1092047662 81.72.236.131 (9 Aug 2004 03:34:22 -0700) Lines: 46 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