尝试在VS 2013中打开但在VS 2008和2005中无法正常工作时,Crystal Report错误缺少参数

时间:2019-01-01 08:30:19

标签: vb.net visual-studio-2013 crystal-reports

我将VS 2005项目转换为VS 2013,一切正常,但Crystal Report给出错误“ Missing Parameter”,所有报表在VS 2005中都可以正常工作,但在VS 2013中给出了相同的错误Missing Parameter

Here is my Code
  Dim crReportDocument As 
 CrystalDecisions.CrystalReports.Engine.ReportDocument
Private Sub OpenReport(ByVal rName As String)
    ClientScript.RegisterStartupScript(Me.Page.GetType(), "popupOpener", 
     "var popup=window.open('" + rName.ToString + 
   "','','width=768,height=715,resizable=yes,menubar=0,
    scrollbars=yes,top=0,left= 
     0');popup.focus();", True)
    End Sub
Private Sub GetReport(ByVal DocumentNo As String, ByVal FromDocumentDate As 
  String, ByVal ToDocumentDate As String, ByVal ReportType As String)


    Dim sParameter(2) As String
    Dim sParameterValue(2) As String
    Dim NewDocumentNo() As String = DocumentNo.Split("|")
    Dim NewFromDocumentDate() As String = FromDocumentDate.Split("|")
    Dim NewToDocumentDate() As String = ToDocumentDate.Split("|")

    DocumentNo = ""
    FromDocumentDate = ""
    ToDocumentDate = ""

    For i = 0 To NewDocumentNo.Length
        If i <> NewDocumentNo.Length Then
            If NewDocumentNo.Length = 1 Then
                DocumentNo = "'" & NewDocumentNo(i) & "'"
                FromDocumentDate = "'" & NewFromDocumentDate(i) & "'"
                ToDocumentDate = "'" & NewToDocumentDate(i) & "'"
            Else
                DocumentNo = DocumentNo & "'" & NewDocumentNo(i) & "'" & ","
                FromDocumentDate = FromDocumentDate & "'" & NewFromDocumentDate(i) & "'" & ","
                ToDocumentDate = ToDocumentDate & "'" & NewToDocumentDate(i) & "'" & ","
            End If
        End If
    Next

    If NewDocumentNo.Length > 1 Then
        DocumentNo = Left(DocumentNo, DocumentNo.LastIndexOf(","))
        FromDocumentDate = Left(FromDocumentDate, FromDocumentDate.LastIndexOf(","))
        ToDocumentDate = Left(ToDocumentDate, ToDocumentDate.LastIndexOf(","))
    End If
    sParameterValue(1) = " Where C.Transaction_No <> 0 And A.Document_No IN (" & DocumentNo & ")"




    Dim rName As String
    Dim _Report As New rptObject
    crReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument

    Select Case ReportType
        Case "Cheque"
            rName = "rptCheque"
            crReportDocument.Load(Server.MapPath("../Reports/" + rName + ".rpt"))
            With _Report
                .AddParameter("@WhereCond", sParameterValue(1), crReportDocument)
            End With
            'Case "ITXJournal"
            '    rName = "rptITXJournalVoucher"
            '    crReportDocument.Load(Server.MapPath("../Reports/" + rName + ".rpt"))
            '    With _Report
            '        .AddParameter("User Name", Session("UserName"), crReportDocument)
            '        .AddParameter("@WhereCond", sParameterValue(1), crReportDocument)
            '    End With
            'Case "ITXCashPaymemt"
            '    rName = "rptITXTransactionDetail"
            '    crReportDocument.Load(Server.MapPath("../Reports/" + rName + ".rpt"))
            '    With _Report
            '        .AddParameter("User Name", Session("UserName"), crReportDocument)
            '        .AddParameter("@WhereCond", sParameterValue(1), crReportDocument)
            '    End With
            'Case "Journal"
            '    rName = "rptJournalVoucher"
            '    crReportDocument.Load(Server.MapPath("../Reports/" + rName + ".rpt"))
            '    With _Report
            '        .AddParameter("User Name", Session("UserName"), crReportDocument)
            '        .AddParameter("@WhereCond", sParameterValue(1), crReportDocument)
            '    End With
        Case Else
            rName = "rptGLTransactionDetail"
            ''  rName = "GLReport"
            crReportDocument.Load(Server.MapPath("../Reports/" + rName + ".rpt"))
            With _Report
                .AddParameter("UserName", Session("UserName"), crReportDocument)
                .AddParameter("CompanyName", Session("CompanyName"), crReportDocument)
                .AddParameter("VoucherHeading", "Heading", crReportDocument)
                .AddParameter("@WhereCond", sParameterValue(1), crReportDocument)
            End With
    End Select

    crReportDocument.DataSourceConnections.Item(0).SetConnection("KT", "JVC", True)
    If cboReportFormat.SelectedValue.Equals("pdf") Then
        crReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, 
      System.Web.HttpContext.Current.Server.MapPath("../Reports/" + rName + 
 ".pdf"))
        'Call 
  OpenReport(System.Web.HttpContext.Current.Server.MapPath("../Reports/" + 
 rName + ".pdf"))
    Else
        crReportDocument.ExportToDisk(ExportFormatType.Excel, 
      System.Web.HttpContext.Current.Server.MapPath("../Reports/" + rName + 
   ".xls"))
        'Call 
  OpenReport(System.Web.HttpContext.Current.Server.MapPath("../Reports/" + 
          rName + ".xls"))
    End If
    OpenReport("../Reports/" + rName + "." + cboReportFormat.SelectedValue)
End Sub
#End Region    

有时会运行报表,但不带参数并显示所有记录,有时会给出错误的“缺少参数”

0 个答案:

没有答案
相关问题