Results 1 to 5 of 5

Thread: OleDbParameters filter for Date? {RESOLVED}

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54

    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.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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.

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    by the way, isnt 'Date' a reserved word?

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54
    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.

  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    '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
  •  



Click Here to Expand Forum to Full Width