在水晶报告中渲染300k记录仅显示1条记录

时间:2018-04-10 00:47:16

标签: vb.net crystal-reports

我是Crystal Reports的新手,我正在尝试从数据库中渲染行。当我尝试少于10万行时,报告工作正常,但当我尝试使用更多记录时,报告只显示一行

如果我查看数据源的行,则 300k行Row Count

但此报告的输出只有一行: Error Output

但如果行数较低(9k行): 9k rows

它运作得很好: Correct Output

Try
    '//get values from page parameter and set values to crystalreport interface object
    vo.reportalias = Request.QueryString("reportname")
    vo.reporttype = Request.QueryString("reporttype")
    vo.SPName = Request.QueryString("spr")
    vo.ReportName = Request.QueryString("rpt")
    vo.MonthName = Request.QueryString("Monthname")
    vo.Year = Request.QueryString("year")
    vo.Month = Request.QueryString("month")
    vo.CustAccnt = Request.QueryString("CustAccnt")

    If IsDate(Request.QueryString("date")) Then
        vo.DateDaily = Request.QueryString("date")
        vo.Week = Request.QueryString("date")
    End If
    If IsDate(Request.QueryString("datefrom")) Then vo.DateFrom = Request.QueryString("datefrom")
    If IsDate(Request.QueryString("dateto")) Then vo.DateTo = Request.QueryString("dateto")

    '//generate session name
    strSessionName = vo.reportalias.ToString + vo.reporttype.ToString + vo.SPName.ToString + vo.ReportName.ToString

    If vo.MonthName <> Nothing Then strSessionName = strSessionName + vo.MonthName.ToString
    If vo.Year <> Nothing Then strSessionName = strSessionName + vo.Year.ToString
    If vo.Month <> Nothing Then strSessionName = strSessionName + vo.Month.ToString
    If vo.DateDaily <> Nothing Then strSessionName = strSessionName + vo.DateDaily.ToString
    If vo.Week <> Nothing Then strSessionName = strSessionName + vo.Week.ToString
    If vo.DateFrom <> Nothing Then strSessionName = strSessionName + vo.DateFrom.ToString
    If vo.DateTo <> Nothing Then strSessionName = strSessionName + vo.DateTo
    If vo.CustAccnt <> Nothing Then strSessionName = strSessionName + vo.CustAccnt

    '//test sessions for loading dataset
    If Session(strSessionNameName) = strSessionName Then '//if session exists and new (other report is current)
        ds = Session(strSessionName)
    ElseIf Not Page.IsPostBack And Session(strSessionNameName) <> strSessionName Then '//if new page load
        ds = dao.getRecord(vo)
        Session(strSessionName) = ds
        Session(strSessionNameName) = strSessionName
    ElseIf Page.IsPostBack And IsNothing(Session(strSessionNameName)) Then '//if the session is already destroyed create a new session
        ds = dao.getRecord(vo)
        Session(strSessionName) = ds
        Session(strSessionNameName) = strSessionName
    Else '//if session exists
        ds = Session(strSessionName)
    End If

    '//if dataset returns 0 then exit
    If ds.Tables(0).Rows.Count = 0 Then
        CrystalReportViewer1.Visible = False
        btnExport.Visible = False
        drplstFormat.Visible = False
        Label1.Text = "No record found"
        Label1.Visible = True
        destroyObject()
        Exit Sub
    End If

    '//Set crystal rpt file details
    With cryRpt

        '//set report mapping
        cryRpt.Load (Server.MapPath(vo.ReportName))

        '//set report datasource to ds
        cryRpt.SetDataSource (ds.Tables(0))

        '//test report type for label dislay (report title) on the report
        If (vo.reporttype = vo.enumReportType.MonthName Or _
        vo.reporttype = vo.enumReportType.DateRange) Then
            .SetParameterValue("@ReportName", vo.ReportAlias.ToString.ToUpper())
        Else
            Dim reportalias As String = vo.ReportAlias.ToString.ToUpper()
            Dim reporttype As String = vo.ReportType.ToString.ToUpper()
            .SetParameterValue("@ReportName", vo.ReportAlias.ToString.ToUpper() + " " + vo.ReportType.ToString.ToUpper())
        End If

        '//set hardcoded parameters on report for  display only
        If vo.reporttype = vo.enumReportType.Daily Then '//Dailly
            .SetParameterValue("@DateDaily", vo.DateDaily)
        ElseIf vo.reporttype = vo.enumReportType.Monthly Then '//Monthly
            .SetParameterValue("@DateMonthly", vo.Month)
            .SetParameterValue("@DateYear", vo.Year)
        ElseIf vo.reporttype = vo.enumReportType.DateRange Then '//daterange
            .SetParameterValue("@dateFrom", vo.DateFrom)
            .SetParameterValue("@dateTo", vo.DateTo)
        ElseIf vo.reporttype = vo.enumReportType.MonthName Then '//Monthly with range
            .SetParameterValue("@MonthName", vo.MonthName)
            .SetParameterValue("@Year", vo.Year)
        ElseIf vo.reporttype = vo.enumReportType.Weekly Then  '//week date range
            .SetParameterValue("@dateFrom", vo.DateFrom)
            .SetParameterValue("@dateTo", vo.DateTo)
        ElseIf vo.reporttype = vo.enumReportType.PerUser Then '//Per user with date range
            .SetParameterValue("@dateFrom", vo.DateFrom)
            .SetParameterValue("@dateTo", vo.DateTo)
        End If
    End With

    '//set crystal report viewer report source
    CrystalReportViewer1.ReportSource = cryRpt
    CrystalReportViewer1.DataBind()
    Catch excep As Exception
    Console.WriteLine (excep.Message)
End Try

我也试过把try catch但是它不会捕获任何异常。我在这个项目中使用Visual Basic .net 2003。

0 个答案:

没有答案