Thursday, March 29, 2012

Date Range

------------------------

sqladapter.SelectCommand = New OdbcCommand("SELECT * from " & table & "where date between @.from_date and @.to_date", conn)

sqladapter.SelectCommand.Parameters.Add("@.from_dat e", OdbcType.date, "date").Value = Me.DateTimePicker1.Value.ToShortDateString

sqladapter.SelectCommand.Parameters.Add("@.to_date" , OdbcType.date, "date").Value = Me.DateTimePicker2.Value.ToShortDateString

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

how do i solve the prob? any idea?

Quote:

Originally Posted by girl

------------------------

sqladapter.SelectCommand = New OdbcCommand("SELECT * from " & table & "where date between @.from_date and @.to_date", conn)

sqladapter.SelectCommand.Parameters.Add("@.from_dat e", OdbcType.date, "date").Value = Me.DateTimePicker1.Value.ToShortDateString

sqladapter.SelectCommand.Parameters.Add("@.to_date" , OdbcType.date, "date").Value = Me.DateTimePicker2.Value.ToShortDateString

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

how do i solve the prob? any idea?


Add single quote

' "& table & " '

sqladapter.SelectCommand = New OdbcCommand("SELECT * from '" & table & "' where date between @.from_date and @.to_date", conn)|||sqladapter.SelectCommand = New OdbcCommand("SELECT * from '" & table & "'where date between @.from_date and @.to_date", conn)

sqladapter.SelectCommand.Parameters.Add("@.from_date", OdbcType.Date).Value = Me.MonthCalendar1.SelectionStart.Date

sqladapter.SelectCommand.Parameters.Add("@.to_date", OdbcType.Date).Value = Me.MonthCalendar2.SelectionEnd.Date

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

i did what you say but it prompt me @. the .fill statement
Optional feature not included!! what should i do??

No comments:

Post a Comment