BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Query not returning results

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Mike
Guest





PostPosted: Wed Aug 11, 2004 4:34 am    Post subject: SQL Query not returning results Reply with quote



Hi,
I have tried all the suggestions but nothing seems to work, (But I am not
getting the ODBC Error now). That is I am not getting the results for the
query. If I run the same query in the query analyser of SQL I get my result.

The senario is like this. I have a table WKItems which contains transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records. But if i
query for transactions between '01/08/2004' and '02/08/2004' I get the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote

Quote:

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears when I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]




Back to top
Viatcheslav V. Vassiliev
Guest





PostPosted: Wed Aug 11, 2004 7:06 am    Post subject: Re: SQL Query not returning results Reply with quote



Datetime paramters represent not only date but time too, so if you have no
records for 01/08/2004 00:00, you get no records for first query. The second
query should return records in interval 01/08/2004 00:00 - 02/08/2004 00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi,
I have tried all the suggestions but nothing seems to work, (But I am not
getting the ODBC Error now). That is I am not getting the results for the
query. If I run the same query in the query analyser of SQL I get my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records. But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]






Back to top
treok
Guest





PostPosted: Wed Aug 11, 2004 7:30 am    Post subject: Re: SQL Query not returning results Reply with quote



Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime) between
'01/08/2004' and '01/08/2004'



Quote:
Datetime paramters represent not only date but time too, so if you have
no
records for 01/08/2004 00:00, you get no records for first query. The
second
query should return records in interval 01/08/2004 00:00 - 02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work, (But I am
not
getting the ODBC Error now). That is I am not getting the results for
the
query. If I run the same query in the query analyser of SQL I get my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com

Back to top
Viatcheslav V. Vassiliev
Guest





PostPosted: Wed Aug 11, 2004 11:10 am    Post subject: Re: SQL Query not returning results Reply with quote

How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Quote:
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime) between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if you have
no
records for 01/08/2004 00:00, you get no records for first query. The
second
query should return records in interval 01/08/2004 00:00 - 02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work, (But I am
not
getting the ODBC Error now). That is I am not getting the results for
the
query. If I run the same query in the query analyser of SQL I get my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com



Back to top
Mike
Guest





PostPosted: Wed Aug 11, 2004 2:20 pm    Post subject: Re: SQL Query not returning results Reply with quote

Hi,

I tried out the suggestion and the following worked.

convert(varchar(10),transdate,103) between :mfrom and :mto

"Mike" <myqro (AT) yahoo (DOT) com> wrote

Quote:
Hi,
I have tried all the suggestions but nothing seems to work, (But I am not
getting the ODBC Error now). That is I am not getting the results for the
query. If I run the same query in the query analyser of SQL I get my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records. But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]






Back to top
Mike
Guest





PostPosted: Fri Aug 13, 2004 12:23 pm    Post subject: Re: SQL Query not returning results Reply with quote

Hi,
The Query results are not correctly returned.

The Query defined as:

Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where convert(varchar(10),startdate,103) between :mfrom and :mto
Order by cast(Jobcard As Int)

1. I am using a TadoQuery.
2. Startdate is of type datetime

When i run the query now with mfrom = '01/08/2004' and mto = '13/08/2004' I
get all transactions posted in WkJobcard. But if i select mfrom =
'12/08/2004' and mto = '12/08/2004' i only get transactions for '12/08/2004'
which is correct.

Please help in resolving this!!!!

Thanks
Mike

"Viatcheslav V. Vassiliev" <support (AT) oledbdirect (DOT) com> wrote

Quote:
How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime) between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if you have
no
records for 01/08/2004 00:00, you get no records for first query. The
second
query should return records in interval 01/08/2004 00:00 - 02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work, (But I am
not
getting the ODBC Error now). That is I am not getting the results for
the
query. If I run the same query in the query analyser of SQL I get my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get
the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com





Back to top
Vitali Kalinin
Guest





PostPosted: Fri Aug 13, 2004 12:40 pm    Post subject: Re: SQL Query not returning results Reply with quote

Thats because you had removed back casting to datetime (see original post of
treok). Also Viatcheslav's advice still apply, you should take into account
time part of DateTime value.
"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:411cb302 (AT) newsgroups (DOT) borland.com...
Quote:
Hi,
The Query results are not correctly returned.

The Query defined as:

Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where convert(varchar(10),startdate,103) between :mfrom and :mto
Order by cast(Jobcard As Int)

1. I am using a TadoQuery.
2. Startdate is of type datetime

When i run the query now with mfrom = '01/08/2004' and mto = '13/08/2004'
I
get all transactions posted in WkJobcard. But if i select mfrom =
'12/08/2004' and mto = '12/08/2004' i only get transactions for
'12/08/2004'
which is correct.

Please help in resolving this!!!!

Thanks
Mike

"Viatcheslav V. Vassiliev" <support (AT) oledbdirect (DOT) com> wrote in message
news:4119fea8$1 (AT) newsgroups (DOT) borland.com...
How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях
следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime)
between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if you
have
no
records for 01/08/2004 00:00, you get no records for first query. The
second
query should return records in interval 01/08/2004 00:00 - 02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work, (But I
am
not
getting the ODBC Error now). That is I am not getting the results
for
the
query. If I run the same query in the query analyser of SQL I get
my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0 records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I get
the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error
appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com







Back to top
Mike
Guest





PostPosted: Fri Aug 13, 2004 2:13 pm    Post subject: Re: SQL Query not returning results Reply with quote

I removed the cast into datetime because it was generating an error 'The
conversion of a char data type to a datetime resulted in an out-of-range
datetime value'.

Thanks
Mike

"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> wrote

Quote:
Thats because you had removed back casting to datetime (see original post
of
treok). Also Viatcheslav's advice still apply, you should take into
account
time part of DateTime value.
"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:411cb302 (AT) newsgroups (DOT) borland.com...
Hi,
The Query results are not correctly returned.

The Query defined as:

Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where convert(varchar(10),startdate,103) between :mfrom and :mto
Order by cast(Jobcard As Int)

1. I am using a TadoQuery.
2. Startdate is of type datetime

When i run the query now with mfrom = '01/08/2004' and mto =
'13/08/2004'
I
get all transactions posted in WkJobcard. But if i select mfrom =
'12/08/2004' and mto = '12/08/2004' i only get transactions for
'12/08/2004'
which is correct.

Please help in resolving this!!!!

Thanks
Mike

"Viatcheslav V. Vassiliev" <support (AT) oledbdirect (DOT) com> wrote in message
news:4119fea8$1 (AT) newsgroups (DOT) borland.com...
How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях
следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime)
between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if you
have
no
records for 01/08/2004 00:00, you get no records for first query.
The
second
query should return records in interval 01/08/2004 00:00 -
02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work, (But
I
am
not
getting the ODBC Error now). That is I am not getting the results
for
the
query. If I run the same query in the query analyser of SQL I get
my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail for
a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0
records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I
get
the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error
appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com









Back to top
Vitali Kalinin
Guest





PostPosted: Fri Aug 13, 2004 3:27 pm    Post subject: Re: SQL Query not returning results Reply with quote

You can give a try to one of this variants:
1. Replace 103 with 100 or whatever would be appropriate to Date Format
settings of yours MS SQL server
2. Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where DateDiff(day,startdate,:mfrom)>=0 and DateDiff(day,startdate,:mto)<=0
Order by cast(Jobcard As Int)
3. Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where startdate>=:mfrom and startdate<DateAdd(day, 1, :mto)
Order by cast(Jobcard As Int)
"Mike" news:411ccc99 (AT) newsgroups (DOT) borland.com...
Quote:
I removed the cast into datetime because it was generating an error 'The
conversion of a char data type to a datetime resulted in an out-of-range
datetime value'.

Thanks
Mike

"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> wrote in message
news:411cb732 (AT) newsgroups (DOT) borland.com...
Thats because you had removed back casting to datetime (see original
post
of
treok). Also Viatcheslav's advice still apply, you should take into
account
time part of DateTime value.
"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:411cb302 (AT) newsgroups (DOT) borland.com...
Hi,
The Query results are not correctly returned.

The Query defined as:

Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where convert(varchar(10),startdate,103) between :mfrom and :mto
Order by cast(Jobcard As Int)

1. I am using a TadoQuery.
2. Startdate is of type datetime

When i run the query now with mfrom = '01/08/2004' and mto =
'13/08/2004'
I
get all transactions posted in WkJobcard. But if i select mfrom =
'12/08/2004' and mto = '12/08/2004' i only get transactions for
'12/08/2004'
which is correct.

Please help in resolving this!!!!

Thanks
Mike

"Viatcheslav V. Vassiliev" <support (AT) oledbdirect (DOT) com> wrote in message
news:4119fea8$1 (AT) newsgroups (DOT) borland.com...
How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях
следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime)
between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if
you
have
no
records for 01/08/2004 00:00, you get no records for first query.
The
second
query should return records in interval 01/08/2004 00:00 -
02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work,
(But
I
am
not
getting the ODBC Error now). That is I am not getting the
results
for
the
query. If I run the same query in the query analyser of SQL I
get
my
result.

The senario is like this. I have a table WKItems which contains
transactions
entered on a day to day basis. I want to print an audit trail
for
a
specified period say '01/08/2004' so when i put my query as all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0
records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004' I
get
the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error
appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com











Back to top
Mike
Guest





PostPosted: Mon Aug 16, 2004 5:07 am    Post subject: Re: SQL Query not returning results Reply with quote

Still does not work!!.

MIKE

"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> wrote

Quote:
You can give a try to one of this variants:
1. Replace 103 with 100 or whatever would be appropriate to Date Format
settings of yours MS SQL server
2. Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where DateDiff(day,startdate,:mfrom)>=0 and
DateDiff(day,startdate,:mto)<=0
Order by cast(Jobcard As Int)
3. Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where startdate>=:mfrom and startdate<DateAdd(day, 1, :mto)
Order by cast(Jobcard As Int)
"Mike" news:411ccc99 (AT) newsgroups (DOT) borland.com...
I removed the cast into datetime because it was generating an error 'The
conversion of a char data type to a datetime resulted in an out-of-range
datetime value'.

Thanks
Mike

"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> wrote in message
news:411cb732 (AT) newsgroups (DOT) borland.com...
Thats because you had removed back casting to datetime (see original
post
of
treok). Also Viatcheslav's advice still apply, you should take into
account
time part of DateTime value.
"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:411cb302 (AT) newsgroups (DOT) borland.com...
Hi,
The Query results are not correctly returned.

The Query defined as:

Select Jobcard, Startdate, Enddate, customer, regno, Jobtype, Status
From WKJobcard
Where convert(varchar(10),startdate,103) between :mfrom and :mto
Order by cast(Jobcard As Int)

1. I am using a TadoQuery.
2. Startdate is of type datetime

When i run the query now with mfrom = '01/08/2004' and mto =
'13/08/2004'
I
get all transactions posted in WkJobcard. But if i select mfrom =
'12/08/2004' and mto = '12/08/2004' i only get transactions for
'12/08/2004'
which is correct.

Please help in resolving this!!!!

Thanks
Mike

"Viatcheslav V. Vassiliev" <support (AT) oledbdirect (DOT) com> wrote in
message
news:4119fea8$1 (AT) newsgroups (DOT) borland.com...
How exactly looks SQL statement that is passed to ADO, not in QA?

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

"treok" <h.k.j.keesmaat (AT) chello (DOT) nl> сообщил/сообщила в новостях
следующее:
news:4119cb11 (AT) newsgroups (DOT) borland.com...
Try this:

where cast(convert(varchar(10),<datetimefield>,103) as datetime)
between
'01/08/2004' and '01/08/2004'



Datetime paramters represent not only date but time too, so if
you
have
no
records for 01/08/2004 00:00, you get no records for first
query.
The
second
query should return records in interval 01/08/2004 00:00 -
02/08/2004
00:00
as it does.

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

"Mike" <myqro (AT) yahoo (DOT) com> сообщил/сообщила в новостях следующее:
news:4119a1e1 (AT) newsgroups (DOT) borland.com...
Hi,
I have tried all the suggestions but nothing seems to work,
(But
I
am
not
getting the ODBC Error now). That is I am not getting the
results
for
the
query. If I run the same query in the query analyser of SQL I
get
my
result.

The senario is like this. I have a table WKItems which
contains
transactions
entered on a day to day basis. I want to print an audit trail
for
a
specified period say '01/08/2004' so when i put my query as
all
transactions
between '01/08/2004' and '01/08/2004', the query returns 0
records.
But if
i
query for transactions between '01/08/2004' and '02/08/2004'
I
get
the
records for '01/08/2004'.

Any more suggestions???

Thanks,
Mike
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:n0fgh0l04h8e50k43h5p6digahsqp43n4v (AT) 4ax (DOT) com...

Is there anybody who can hel in resolving this error.

I am using MSSQL 2000 and Delphi 7 enterprise. This error
appears
when
I
execute the following TADOQuery:

I suggest you use the OleDB driver for SQL server
There are database features that don't work with ODBC
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]









--- posted by geoForum on http://delphi.newswhat.com













Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.