我有一个使用 ASP.NET 4.5 和 reportviewer 版本 11 在本地模式下运行的基于 Web 的 reportviewer。我想用数据表填充它。数据表被填充,但是当我运行报告时,只有工具栏显示没有报告表或显示错误。
这是我的代码:
Protected Sub ButtonRunReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonRunReport.Click
ReportViewer1.Reset()
ReportViewer1.LocalReport.ReportPath = "LMS/ParticipantListSummary.rdlc"
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("LMS_ParticipantListSummary", GetDataTable("Participant List")))
ReportViewerDiv.Visible = True
ReportViewer1.LocalReport.SetParameters(parameters)
ReportViewer1.Visible = True
ReportViewer1.Style.Item("display") = ""
PanelOpeningMessage.Style.Item("display") = "none"
ReportViewer1.LocalReport.Refresh()
End Sub
Private Function GetDataTable(ByVal reportType As String) As DataTable
Dim dt As New DataTable
Dim connectionString = ConfigurationManager.ConnectionStrings("LMSConnectionString").ConnectionString
Dim cmdText As String = ... //command text string not shown.
Using cn As New SqlConnection(connectionString)
Dim dt As New DataTable()
Dim state As ConnectionState = connection.State
Dim adapter As New SqlDataAdapter(cmdText, cn)
If state = ConnectionState.Closed Then
connection.Open()
End If
adapter.Fill(dt)
If state = ConnectionState.Open Then
connection.Close()
End If
End Using
return dt
End Function
有任何想法吗?
谢谢,贾斯汀。
PS忘了提到这在reportviewer 10版上运行良好。