Bind DataTable to RDLC and ReportViewer

独自空忆成欢 提交于 2019-12-03 16:59:10

Some things to check: "Test Report" must be the name used in the report designer. It's case sensitive. The dt must match the name used in the report designer too "Your report Path" should be of the form "namespace.reportname.rdlc" . It's case sensitive.

EDIT: The approach I normally use utilises an extra layer, in the form of a BindingSource as follows: Fill a strongly-typed dataset using the ad-hoc query and a SqlDataAdapter. Dim a Bindingsource and set its DataSource to the dataset and its DataMember to the table name. Dim a ReportDataSource and set its name to the name used in the report designer, and its value to the BindingSource eg

 Using cn As New SqlConnection(gcs)
        cn.Open()
        Dim sa As New SqlDataAdapter(sql, cn)
        sa.SelectCommand.CommandTimeout = cGlobals.ReportTimeout
        sa.Fill(ds, "Foos")
    End Using
    bs.DataSource = ds
    bs.DataMember = "Foos"
    Dim rds As New ReportDataSource
    rds.Name = "dsFooList_Foos"
    rds.Value = bs
    rv1.LocalReport.DataSources.Add(rds)

    Me.Show()
    rv1.RefreshReport()

Edit 2: At the point in your screenshot, drop down the datasources and pick the one you want. It will then appear in the Report Data window, which may be hiding in the 'View' menu (it's only there when you're working with a report) Then you can add a Table to the report from the toolbox, and then drag the fields from the Report Data window to the table cells.

dovla091

something similar I have made for my "report loader", please check this link, it is written in C# but it will give you an idea how to do it.

How to bind dynamically datasource to reportviewer on windows forms c#

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!