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)

Thanks!

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"))

    rvSS.LocalReport.DataSources.Clear()
    rvSS.LocalReport.DataSources.Add(myRDS)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.