如何在VS Visual Studio 2010 Basic中的报表查看器中加载带有参数的.rdlc报表?

时间:2013-03-29 12:45:49

标签: parameters report rdlc

我不知道是什么问题,我的笔记中有相同的代码。报表查看器不会使用参数加载.rdlc报表。我有相同的对象名称和参数名称。我在报表查看器的小箭头链接中选择了.rdlc报表。所以请放心,它应该将.rdlc与报表查看器连接,我有以下代码。

导入Microsoft.Reporting.WinForms

Public Class PrintSingleInfo

Private Sub PrintSingleInfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim pn, bn, ad, cn, sr, lt, lb, ls, ln, dd, lp, pc, tb, dp, tp, dr, ir, mp, pt As New ReportParameter
    pn = New ReportParameter("PNPANoPar", MemParkInfoSysForm.PNPANoTextBox.Text)
    bn = New ReportParameter("BuyerNamePar", MemParkInfoSysForm.BuyerNameTextBox.Text)
    ad = New ReportParameter("AddressPar", MemParkInfoSysForm.AddressTextBox.Text)
    cn = New ReportParameter("ContactNoPar", MemParkInfoSysForm.ContactTextBox.Text)
    sr = New ReportParameter("SalesRepPar", MemParkInfoSysForm.SalesRepTextBox.Text)
    lt = New ReportParameter("TypePar", MemParkInfoSysForm.TypeCBO.Text)
    ls = New ReportParameter("SectionPar", MemParkInfoSysForm.SectionTextBox.Text)
    lb = New ReportParameter("BlockPar", MemParkInfoSysForm.BlockTextBox.Text)
    ln = New ReportParameter("LotNoPar", MemParkInfoSysForm.LotNoTextBox.Text)
    dd = New ReportParameter("DueDatePar", MemParkInfoSysForm.DueUpDown.Value)
    lp = New ReportParameter("LotPricePar", MemParkInfoSysForm.LBLPrice.Text)
    pc = New ReportParameter("PerpetualCarePar", MemParkInfoSysForm.LBLPerpCare.Text)
    tp = New ReportParameter("TotalLotPricePar", MemParkInfoSysForm.LBLTotLotPrice.Text)
    dp = New ReportParameter("DownPaymentPar", MemParkInfoSysForm.DownpaymentTextBox.Text)
    tb = New ReportParameter("LotBalancePar", MemParkInfoSysForm.LBLLotBal.Text)
    pt = New ReportParameter("PaymentTermsPar", MemParkInfoSysForm.PaymentTermsCBO.Text)
    ir = New ReportParameter("InterestRatePar", MemParkInfoSysForm.LBLInterest.Text)
    dr = New ReportParameter("DiscountRatePar", MemParkInfoSysForm.LBLDiscount.Text)
    mp = New ReportParameter("MonthlyPaymentPar", MemParkInfoSysForm.LBLMonthly.Text)



    ReportViewer1.LocalReport.SetParameters(pn)
    ReportViewer1.LocalReport.SetParameters(bn)
    ReportViewer1.LocalReport.SetParameters(ad)
    ReportViewer1.LocalReport.SetParameters(cn)
    ReportViewer1.LocalReport.SetParameters(sr)
    ReportViewer1.LocalReport.SetParameters(lt)
    ReportViewer1.LocalReport.SetParameters(ls)
    ReportViewer1.LocalReport.SetParameters(lb)
    ReportViewer1.LocalReport.SetParameters(ln)
    ReportViewer1.LocalReport.SetParameters(dd)
    ReportViewer1.LocalReport.SetParameters(lp)
    ReportViewer1.LocalReport.SetParameters(pc)
    ReportViewer1.LocalReport.SetParameters(tp)
    ReportViewer1.LocalReport.SetParameters(dp)
    ReportViewer1.LocalReport.SetParameters(tb)
    ReportViewer1.LocalReport.SetParameters(pt)
    ReportViewer1.LocalReport.SetParameters(ir)
    ReportViewer1.LocalReport.SetParameters(dr)
    ReportViewer1.LocalReport.SetParameters(mp)
    Me.ReportViewer1.RefreshReport()
End Sub

结束班

1 个答案:

答案 0 :(得分:0)

请尝试使用reportparameter列表,而不是您的方法。

创建列表,将每个报表参数对象添加到其中,然后将列表传递给

ReportViewer1.LocalReport.SetParameters()
希望有所帮助!