473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SELECT problem using ADO

Hello,

I have a database with one table (tblTest) which has two columns (id
(int) and ts (date/time)). In this table I want to select all records
between to times using the following query:

SELECT * FROM tblTest WHERE (ts >= #1/1/2007# And ts <= #12/31/2007
23:59:0#);

or

SELECT * FROM tblTest WHERE (ts BETWEEN #1/1/2007# And #12/31/2007
23:59:0#);

This works without problems when entered in Access. But, performing a
query using ADO from a C++ application this gives the following
exception (translated from Swedish).

"The parameter object is badly defined. The supplied information is
inconsistent or incomplete"

If I only use dates instead of date + time then everything works ok.
Does anyone know why this happens?

Nov 7 '07 #1
1 1378
k.******@gmail.com wrote in news:1194428413.059945.321970
@o80g2000hse.googlegroups.com:
Hello,

I have a database with one table (tblTest) which has two columns (id
(int) and ts (date/time)). In this table I want to select all records
between to times using the following query:

SELECT * FROM tblTest WHERE (ts >= #1/1/2007# And ts <= #12/31/2007
23:59:0#);

or

SELECT * FROM tblTest WHERE (ts BETWEEN #1/1/2007# And #12/31/2007
23:59:0#);

This works without problems when entered in Access. But, performing a
query using ADO from a C++ application this gives the following
exception (translated from Swedish).

"The parameter object is badly defined. The supplied information is
inconsistent or incomplete"

If I only use dates instead of date + time then everything works ok.
Does anyone know why this happens?
I suspect ODBC helps iterpret #12/31/2007 23:59:00# correctly. (Is it not a
barbaric construction?).

With ADO I would use
CAST('2007-12-31 23:59:00' As DateTime) or SmallDateTime depending on the
size of the field.

Upon further review I would use
WHERE YEAR(ts) = 2007

--
lyle fairfield
Nov 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
3
by: Memduh Durmaz | last post by:
Hi, I'm using DB2 UDB 7.2. Also I'm doing some tests on SQL Server 2000 for some statements to use efectively. I didn't find any solution on Sql Server about WITH ... SELECT structure of DB2. ...
6
by: RCS | last post by:
I've been running into more and more complexity with an application, because as time goes on - we need more and more high-level, rolled-up information. And so I've created views, and views that use...
6
by: Sjaakie | last post by:
Hi there, I'm trying to get this working with Firefox. Can you point out what's wrong? No problems with IE, Firefox doens't fill selMonth... TIA >>> the script... >>> <select name="selDay"...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
2
by: Pavel Stehule | last post by:
Hello, Pg make query 1. and 2. very fast (use index), but for query 3. dont use index. I can solve its using select union, but I readed so pg 7.5 don't problem with OR operator. I use cvs pg. I...
1
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.