none
有关vs2010 web开发中ReportViewer钻取报表的问题 RRS feed

  • 问题

    • 一个PUBSDataSet2.xsd下的两个数据表,数据集为dataset1和dataset2分别指向两个rdlc报表文件,默认显示report2对应dataset1,点击pub_id链接到report报表对应dataset2,筛选参数等于该pub_id,实现父子表的钻取功能。但是总是不成功,照着网上的代码设了n次,都是钻取时显示尚未为数据源“DataSet2”提供数据源实例,到底该如何为DataSet2提供实例呢?
        Protected Sub ReportViewer1_Drillthrough(ByVal sender As Object, ByVal e As Microsoft.Reporting.WebForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
            If ReportViewer1.LocalReport.ReportPath = "Report2.rdlc" Then
                Dim localReport = e.Report
                Dim pubid = e.Report.GetParameters("pubid").Values(0).Trim()
                ReportViewer1.LocalReport.ReportPath = "Report.rdlc"
                Dim rep1 As New Microsoft.Reporting.WebForms.ReportDataSource("DataSet2", loadReportData(pubid))
                ReportViewer1.LocalReport.DataSources.Clear()
                ReportViewer1.LocalReport.DataSources.Add(rep1)
                ReportViewer1.LocalReport.Refresh()
            End If
        End Sub
        Function loadReportData(ByVal pama As String) As Data.DataTable
            Dim tmstr As String
            tmstr = "select * from employee where pub_id = '" + pama + "'"
            Dim sql1 As New System.Data.SqlClient.SqlDataAdapter(tmstr, "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\QQDownload\PUBS.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True")
            Dim rs1 As New Data.DataSet
            rs1.Clear()
            sql1.Fill(rs1)
            Return rs1.Tables(0)
        End Function


    2012年8月18日 3:11

答案