473,471 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1533
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.