报表查看器 VB.NET
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22027526/
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
Report Viewer VB.NET
提问by Jim Buckley Barret
I'm just trying to figure out how to use Report Viewer in VB.NET.
我只是想弄清楚如何在 VB.NET 中使用报表查看器。
The report has only one text box with the data element name set to ReportName.
该报告只有一个文本框,其数据元素名称设置为 ReportName。
The code is simple.
代码很简单。
Private Sub frmCalibrationPreviewReport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If _CalibrationReportID <> -1 Then
With rvCalibrationReport
.LocalReport.DataSources.Clear()
.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
Dim tmpData As DataTable = modDeclare.SelectSQL("SELECT ReportName FROM tblReportTypes")
.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData))
End With
End If
Me.rvCalibrationReport.RefreshReport()
End Sub
Nothing is appearing on the report, it should contain two records.
报告中没有出现任何内容,它应该包含两条记录。
Where am I going wrong?
我哪里错了?
Jim
吉姆
回答by ???ěxě?
Here's a great article covering Report Viewer
这是一篇涵盖报表查看器的很棒的文章
I mention this link as it appears your new to this. I would recommend reading this first.
我提到了这个链接,因为它看起来是你的新手。我建议先阅读这篇文章。
回答by Ccorock
Try Changing
尝试改变
.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData))
To
到
.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData.defaultview))
I would also suggest looking at this question, very similar to yours...
我还建议看看这个问题,与你的非常相似......
Bind DataTable to RDLC and ReportViewer
将 DataTable 绑定到 RDLC 和 ReportViewer
The problem with this question is there are a lot of gears at work when using reporting in visual studio. The problem could also be in the report file itself (.RDLC) if the field is not referencing the data source correctly. With the limited amount of information all I could suggest is using a working template and slowly adding your desired elements one at a time.
这个问题的问题是在 Visual Studio 中使用报告时有很多齿轮在工作。.RDLC如果该字段未正确引用数据源,则问题也可能出在报告文件本身 ( ) 中。由于信息量有限,我只能建议使用工作模板并一次缓慢地添加您想要的元素。

