🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with access database

#417
From: Erol Fornoles
Date: Sat, 18 Nov 2006 16:12
37 lines
2436 bytes
Use parameters instead of having the datetime values directly on your
SQL. Assuming you're using TADOQuery:

SQL = "SELECT * FROM events WHERE started >= :DT_START and started <=
:DT_END;

Then populate both DT_START and DT_END parameters with the needed
date-time values.

On Nov 18, 1:12 am, Daniel <m...@eesensors.com> wrote:
> Hello,
>
>      I am using BCB6, Access 2003 and ADO for a small application. I
> have a problem when I use datetime string in SQL.
>      My code list blow,
>      ...
>      sql = "SELECT * FROM events WHERE started >= #11/12/2006# and
> started <= #11/17/2006 11:56:32#";
>      ...
>      adoQuery->Open();
>      ...
>      Then I got error message, "Parameter object is improperly defined.
> Inconsistent or incomplete information was provided.".
>      So I found out if I do like this,
>      ...
>      sql = "SELECT * FROM events WHERE started >= #11/12/2006# and
> started <= #11/17/2006#";
>      ...
>      adoQuery->Open();
>      ...
>      This time it works. But both sql can be executed in Access if I
> just open query in Access.
>      The 'started' field is DATE/TIME type in table Events.
> 
>      How do I fix it to query with time?
> 
> Thank
Technical Details
Message-ID: <1163866358.013554.269090@k70g2000cwa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail
References: <455dedf8@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,26d1ee675db50154
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail
From: "Erol Fornoles" <erol.fornoles@gmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Problem with access database
Date: 18 Nov 2006 08:12:38 -0800
Organization: http://groups.google.com
Lines: 38
Message-ID: <1163866358.013554.269090@k70g2000cwa.googlegroups.com>
References: <455dedf8@newsgroups.borland.com>
NNTP-Posting-Host: 124.104.7.127
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1163866363 26166 127.0.0.1 (18 Nov 2006 16:12:43 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 18 Nov 2006 16:12:43 +0000 (UTC)
In-Reply-To: <455dedf8@newsgroups.borland.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: k70g2000cwa.googlegroups.com; posting-host=124.104.7.127;
   posting-account=eSwwBg0AAABefeuJ5pOS_k670Rlobybv