Hi! I want to display a table in the Local Report using SQL Connection. Parameters will be user-defined. Example.

sqlSearch = "SELECT * FROM shipment WHERE " & port & " BETWEEN @datePerformedFrom AND @datePerformedTo ORDER BY recno DESC"

@datePerformedFrom and @datePerformedTo will be supplied by the user.

Please help me how can I display this in the Local Report (RDLC)


Simply create a table to store the user supplied @datePerformedFrom and @datePerformedTo. Create a view joining with the table shipment.
Now you can attach this view with ReportViewer object by creating a DataSet.

hi sir! could you help me put it in code? I have a DataGridView already.

Found this on the Internet. It worked!

Dim cmdGet, cmdCount As New iDB2Command
Dim daGet As New iDB2DataAdapter
Dim dsGet As New DataSet

Dim sqlGet, dateFrom, dateTo As String

dateFrom = Format(frmSS.dtFrom.Value, "yyyy-MM-dd")
dateTo = Format(frmSS.dtTo.Value, "yyyy-MM-dd")

'****Get Data and print to report
sqlGet = "SELECT * FROM shipment WHERE etamanila BETWEEN @dateFrom AND @dateTo ORDER BY recno DESC"

    With cmdGet
        .Parameters.AddWithValue("@dateFrom", dateFrom)
        .Parameters.AddWithValue("@dateTo", dateTo)

        .CommandText = sqlGet
        .Connection = conn
    End With

    daGet.SelectCommand = cmdGet
    daGet.Fill(dsGet, "shipment")

    Dim myRDS As New ReportDataSource("dsSS", dsGet.Tables("shipment"))


Also, create a dataset first and bind the source to your reportviewer.

Edited 2 Years Ago by xuexue

This question has already been answered. Start a new discussion instead.