date range problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • girl
    New Member
    • Jun 2007
    • 8

    date range problem

    i have this problem
    m using dataset
    dataadapter and dataset

    i would like to select a date range using a datetimepicker or monthcalendar. the data in my database for date is 05/01/2007 where 05 is the month and 01 is the date.



    sqladapter.Sele ctCommand = New OdbcCommand("SE LECT * from " & table & "where date between @from_date and @to_date", conn)



    sqladapter.Sele ctCommand.Param eters.Add("@fro m_date", OdbcType.date, "date").Val ue = Me.DateTimePick er1.Value.ToSho rtDateString


    sqladapter.Sele ctCommand.Param eters.Add("@to_ date" , OdbcType.date, "date").Val ue = Me.DateTimePick er2.Value.ToSho rtDateString


    i tried these codes but when was prompt error " date type cannot convert to int"

    how do i solve the prob?
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Try converting to date before add them as parameter. HTH.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I always added dates as strings, SQL treated it correctly for date comparisons, insertions and updates

      Comment

      • girl
        New Member
        • Jun 2007
        • 8

        #4
        thnx for all your reply...

        kenobewan , you had mention to convert to date first meaning using convert function? or cast functions??

        Plater, how do you display ur date in string? please teach me!

        and lastly,

        sqladapter.Sele ctCommand = New OdbcCommand("SE LECT * from " & table & " where date between @from_date and @to_date", conn)

        sqladapter.Sele ctCommand.Param eters.Add("@fro m_date", OdbcType.Date). Value = Me.MonthCalenda r1.SelectionRan ge.Start.Date.T oString
        sqladapter.Sele ctCommand.Param eters.Add("@to_ date", OdbcType.Date). Value = Me.MonthCalenda r2.SelectionRan ge.End.Date.ToS tring

        sqladapter.Fill (ds, "" & table & "")

        when i try this, it prompt me optional features to be implemented! ani ideas what error is this?

        thnx!

        Comment

        Working...