473,395 Members | 1,368 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,395 software developers and data experts.

Problem with Data adapter sql statement

JR
I am accessing a MS SQL2000 database. The table has a date field setup as 'Datetime' I then setup a data adapter (VB.Net, windows) as follows
daEmpDiv = New SqlClient.SqlDataAdapter("SELECT EmployeeID, DivisionID, SubDivision_ID FROM tblEmpDivisionDates WHERE EmployeeID = 17 AND Start_Date <= " & Today(), conn

When done no records are retrieved, but when I remove the start_date condition the records are retrieved. I know that I am missing something simple, but I unable to see it. Any help would be greatly appreciated

Thanks, JR :)
Jul 21 '05 #1
4 1529
Change it to Start_Date <= GetDate()
"JR" <an*******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I am accessing a MS SQL2000 database. The table has a date field setup as 'Datetime' I then setup a data adapter (VB.Net, windows) as follows: daEmpDiv = New SqlClient.SqlDataAdapter("SELECT EmployeeID, DivisionID, SubDivision_ID FROM tblEmpDivisionDates WHERE EmployeeID = 17 AND Start_Date
<= " & Today(), conn)
When done no records are retrieved, but when I remove the start_date condition the records are retrieved. I know that I am missing something
simple, but I unable to see it. Any help would be greatly appreciated.
Thanks, JR :)

Jul 21 '05 #2
Change it to Start_Date <= GetDate()
"JR" <an*******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I am accessing a MS SQL2000 database. The table has a date field setup as 'Datetime' I then setup a data adapter (VB.Net, windows) as follows: daEmpDiv = New SqlClient.SqlDataAdapter("SELECT EmployeeID, DivisionID, SubDivision_ID FROM tblEmpDivisionDates WHERE EmployeeID = 17 AND Start_Date
<= " & Today(), conn)
When done no records are retrieved, but when I remove the start_date condition the records are retrieved. I know that I am missing something
simple, but I unable to see it. Any help would be greatly appreciated.
Thanks, JR :)

Jul 21 '05 #3
JR <an*******@discussions.microsoft.com> wrote:
I am accessing a MS SQL2000 database. The table has a date field
setup as 'Datetime' I then setup a data adapter (VB.Net, windows) as
follows:
daEmpDiv = New SqlClient.SqlDataAdapter("SELECT EmployeeID,
DivisionID, SubDivision_ID FROM tblEmpDivisionDates WHERE EmployeeID
= 17 AND Start_Date <= " & Today(), conn)

When done no records are retrieved, but when I remove the start_date
condition the records are retrieved. I know that I am missing
something simple, but I unable to see it. Any help would be greatly
appreciated.


Instead of embedding the date directly in the SQL, use a parameter and
set the value of that parameter to today's date. That way you won't
need to worry about conversions and formatting, etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
JR <an*******@discussions.microsoft.com> wrote:
I am accessing a MS SQL2000 database. The table has a date field
setup as 'Datetime' I then setup a data adapter (VB.Net, windows) as
follows:
daEmpDiv = New SqlClient.SqlDataAdapter("SELECT EmployeeID,
DivisionID, SubDivision_ID FROM tblEmpDivisionDates WHERE EmployeeID
= 17 AND Start_Date <= " & Today(), conn)

When done no records are retrieved, but when I remove the start_date
condition the records are retrieved. I know that I am missing
something simple, but I unable to see it. Any help would be greatly
appreciated.


Instead of embedding the date directly in the SQL, use a parameter and
set the value of that parameter to today's date. That way you won't
need to worry about conversions and formatting, etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5

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

Similar topics

5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
0
by: compuglobalhypermeganetz0r | last post by:
I am having trouble getting an adapter to update my access database, it gives the error Syntax error in INSERT INTO statement. for Line 98: Adapter.Update(WineDS, "tblWines") Below is my...
3
by: pmud | last post by:
Hi, I have 2 drop down lists on an asp.Net page. The 1st contains alphabets. When the user selects an alphabet frm the first list, the second drop down list should be populated with names from...
3
by: Al Gerharter | last post by:
Hi, I'm building a form, and tying it to a database via SQL connection, SQLdataadapter, and a Dataset. It appears that the data adapter will not let me select more than 100 fields in the SQL...
2
by: Keith Kuwatani | last post by:
I am using the ODBC .net provider against a pervasive 2000i database. The Data Adapter successfully generates Table Mapping, Select Statement and Insert Statement. However, the Update and Delete...
2
by: Zorpiedoman | last post by:
Up to this point, I have avoided using the Data Adapter to do my updates back to the database. I found it more straight forward to build my own SQL statements, and just execute them directly. ...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
12
by: Simon | last post by:
Hi all, I'm having a baffling problem with a windows service that I'm working on. Basically, I am using a typed dataset to insert a large number of rows into an SQL Server 2005 database. But...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
1
by: M | last post by:
I have the some troubles. I have a VBNET Project version 7.0.9466. Microsoft Visual Basic .NET 55524-640-2187145-18548 I have SQL 2005 and SQL 2000 in different remote computers. When I...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.