🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Daniel Fri, 17 Nov 2006 17:12
Problem with access database
#416
Author: Daniel
Date: Fri, 17 Nov 2006 17:12
27 lines
1708 bytes
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
Re: Problem with access database
#417
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads