Guyz I have a table named fec in which i hv column named EndDt having Date/Time Data type.Now i want to display those records in my report which have EndDt less than Date i pick from DateTimePicker and month is current month.

Private Sub DtpDefault_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DtpDefault.ValueChanged
        Call Connection()
        Dim s As String = Month(Now)
        Dim d As Date = Date.Now
        dsLogin = New DataSet("GymDatDataSet")
        daLogin = New OleDb.OleDbDataAdapter("Select * from fec where Mnth=Month(now) AND EndDt<'" & DtpDefault.Text & "'", con)
        daLogin.Fill(dsLogin, "fec")
        Dim cr As New CrystalReportFeeDefaulter
        cr.SetDataSource(dsLogin)
        CrystalReportViewer1.ReportSource = cr
        CrystalReportViewer1.Refresh()
    End Sub
End Class

Now problem is that i get deata type mismatch error at line daLogin.Fill(dsLogin,"fec")
Pls help me,i need solution urgently

Try this:

Private Sub DtpDefault_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DtpDefault.ValueChanged
        Call Connection()
        Dim s As String = Month(Now)
        Dim d As Date = Date.Now
        dsLogin = New DataSet("GymDatDataSet")
        daLogin = New OleDb.OleDbDataAdapter("Select * from fec where Mnth=Month(now) AND EndDt<'" & DtpDefault.Value.ToString("yyyy-MM-dd") & "'", con)
        daLogin.Fill(dsLogin, "fec")
        Dim cr As New CrystalReportFeeDefaulter
        cr.SetDataSource(dsLogin)
        CrystalReportViewer1.ReportSource = cr
        CrystalReportViewer1.Refresh()
    End Sub
End Class

You can change the argument in ToString into whatever format your dates are stored.

This article has been dead for over six months. Start a new discussion instead.