|
-
Jan 6th, 2003, 03:03 PM
#1
Thread Starter
Member
OleDbParameters filter for Date? {RESOLVED}
In an access db I want to give the user the ability to put search criteria in a combobox and DateTimePicker. Then the report will display their results. I have the OLEDBDataAdapter SelectCommand as follows:
SELECT Date, Customer, Total Sales
FROM CsDB
WHERE (Date >=?) AND (Date<=?) AND (Customer=?);
Then I use the OleDbDataAdapter.SelectCommand.Parameters("Date").Value = DateTimePicker.Text OleDbDataAdapter.SelectCommand.Parameters("Date1).Value = DateTimePicker.Text
OleDbDataAdapter.SelectCommand.Parameters
("Customer").Value = Combobox1.SelectedItem.
This pulls up the customer info, but the problem is it pulls records for all the dates within the parameters and duplicates the customer several times.
Customer # of Orders Total Sales
For example: John Doe 65 4545.20
It makes an entry for every date, then duplicates the customer. I does exactly what the SELECT Statement tells it to do. I can't seem to find a way around it. Anybody got a better way? Thanks..
Last edited by Nintendo_Wizard; Jan 8th, 2003 at 10:47 PM.
-
Jan 7th, 2003, 01:12 PM
#2
Frenzied Member
Try this and see if it helps:
for example:
OleDbDataAdapter.SelectCommand.Parameters("Date1").Value = DateTimePicker.Value.Date
based on your DateTime format in your databse you may have to change the way the value of DateTimePicker is treated.
-
Jan 7th, 2003, 01:12 PM
#3
Frenzied Member
by the way, isnt 'Date' a reserved word?
-
Jan 7th, 2003, 03:47 PM
#4
Thread Starter
Member
Date and Date1 are the names of the OleDbParameters assigned to DateTimePicker1.Text and DateTimePicker2.Text. Basically what I want the query to do is only show the records for "John Doe" that fall within the date range. Instead I get John Doe duplicated for every date in the range. Thanks for your help!
Last edited by Nintendo_Wizard; Jan 7th, 2003 at 05:11 PM.
-
Jan 7th, 2003, 04:46 PM
#5
Frenzied Member
'Date' is a reserved word so if you want to use it in a statment you shoud use it in [] like this:
WHERE ([Date] >=?) AND ([Date]<=?) ....
and the other 'Date' i was talking about was a property of DateTimePicker.Value.
Try comparing DateTime.Now with the followings and see the results:
DateTimePicker1.Text
DateTimePicker1.Value
DateTimePicker1.Value.Date
DateTimePicker1.Value.TimeOfDay
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|