filter microsoft report with date from front end


Well-known member
Jun 2, 2011
Programming Experience
Hi All,
Please kindly help me with this.
I created a microsoft report and used report viewer on a windows form to display data on it. On my report.rdlc, the columns are Expenses Details, Amount and Date. On my form, I have two datetimepicker named dtpFrom and dtpTo. My datetimepicker format is CUSTOM and the customformat is dd-MMM-yyyy. I also have a button named btnShow to display the report. I want to be able to filter my data using the date from my database. The code I'm using is not filtering my report. It just displays every I have on the data base table. Below is my code:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WinForms

Public Class frmReport

    Dim MyConn As New SqlConnection(My.Settings.Ark)
Dim Adapter As SqlDataAdapter
    Dim Adapter1 As SqlDataAdapter
    Dim scb As SqlCommandBuilder
    Dim ds As DataSet

Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
            Dim reportData As New ReportDataSource
 Adapter = New SqlDataAdapter("SELECT BankTransportExp.ExpDetails, BankTransportExp.Amt, BankTransportExp.Date FROM BankTransportExp WHERE BankTransportExp.Date >= '" & CDate(dtpFrom.Text) & "' AND BankTransportExp.Date <= '" & (dtpTo.Text) & "'", MyConn)
            ds = New DataSet
            Adapter.Fill(ds, "BankTransportExp")
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("ATMTechDBDataSet34", ds.Tables("BankTransportExp")))


Pls help me out with the select statement to use in order for the data to be filtered.
Top Bottom