我正在开发Winform Application,我是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
结果我得到的是空白报告请建议我我是新来的报道,我发布的代码是从谷歌推荐的。谢谢,我在等待......
答案 0 :(得分:0)
没有rdlc文件很难回答。我认为问题是您给ReportDataSource
的名称与报告中的数据源名称不匹配。
同时检查ProcessingMode
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local