0

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!

2
Contributors
3
Replies
14
Views
2 Years
Discussion Span
Last Post by xuexue
0

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.

0

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

0

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.

Edited by xuexue

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.