如何在 vb.net 中将 reportdatasource 设置为 rdlc 报告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19738628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set reportdatasource to rdlc report in vb.net?
提问by Vignesh
I am developing Winform Application and i am new to Reports (rdlc). I want to fetch data from database and set them as data source to my report in code. I am using Vb.net and following is my code I tried...
我正在开发 Winform 应用程序,我是 Reports (rdlc) 的新手。我想从数据库中获取数据并将它们设置为我的代码报告的数据源。我正在使用 Vb.net,以下是我尝试过的代码...
Dim conn As OleDbConnection
Dim adpt As OleDbDataAdapter
Dim rs As DataTable
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
conn = New OleDbConnection
conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\tblentries.mdb"
conn.Open()
adpt = New OleDbDataAdapter("select * from tblentries", conn)
rs = New DataTable
adpt.Fill(rs)
Dim ds As DataSet = New DataSet("DataSetOne")
ds.Tables.Add(rs)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Report1", ds.Tables(0)))
ReportViewer1.LocalReport.Refresh()
Me.ReportViewer1.RefreshReport()
End Sub
Result what I am getting is Blank Report Please Suggest me i am new to reporting and the codes i posted are referred from google. Thank you I'm Waiting.....
结果我得到的是空白报告请建议我我是报告的新手,我发布的代码来自谷歌。谢谢我在等......
采纳答案by IvanH
It is difficult to answer without having the rdlc file. I think that the problem is that the name you are giving to ReportDataSourcedoes not match the name of datasource in the report.
没有 rdlc 文件很难回答。我认为问题在于您提供ReportDataSource的名称与报告中数据源的名称不匹配。
Also check ProcessingMode
还要检查 ProcessingMode
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

