使用crytal报告在vb.net 2010中显示报告太慢了

时间:2012-09-25 13:52:16

标签: vb.net crystal-reports report vb.net-2010

我正在使用此代码来显示报告

Dim rpt As New CrystalReport1()

Dim sql As String
Dim where As String




If con Is Nothing OrElse con.State = ConnectionState.Closed Then
    'MsgBox("closed")
    OpenCon()
End If

Dim m As String
m = ""
For Each n As TreeNode In GetCheck(TreeView1.Nodes)
    If n.Tag = 1 Then
        m = m
    Else
        If m = "" Then
            m = (n.Tag)
        Else
            m = m & ", " & (n.Tag)
        End If

    End If

Next

sql = "SELECT [bran_id],[f01],[f02],[f03],[f04],[f05],[f06],[f07],[f08],[bran_name],[comp_id],[comp_name],'" & dtStart.Value.Date & "' AS start_date, '" & dtEnd.Value.Date & "' AS end_date FROM [v_complain]"

If m = "" Then
    MsgBox("لم يتم تحديد اى مدينة من فضلك قم بالاختيار اولا")
    Exit Sub
Else

    where = " WHERE bran_id in (" & m & ") and f02 between CONVERT(date,'" & dtStart.Value.Date & "',103) and CONVERT(date,'" & dtEnd.Value.Date & "',103)"

    sql = sql + where

    If cbF06.Checked = True Then
        where = " AND (f06 like N'') or (f06 is null)"
        sql = sql + where
    End If

    If cbF07.Checked = True Then
        where = " AND (f07 like N'') or (f07 is null)"
        sql = sql + where
    End If


    Dim dscmd As New SqlDataAdapter(sql, con)
    Dim ds As New DataTable

    dscmd.Fill(ds)
    rpt.SetDataSource(ds)
    CrystalReportViewer1.ReportSource = rpt
    CrystalReportViewer1.Refresh()

End If
con.Close()

但是第一次显示报告太慢了。当我尝试再次运行它而不关闭窗口时它完美地工作。有没有办法让它更快?

由于

1 个答案:

答案 0 :(得分:0)

它有多慢?几秒钟? 我认为有必要初始化底层报告'引擎'。我有类似的问题,我能想到的最好的方法是向用户显示“创建报告,请稍候......”消息,以便他们这样做。作为替代方案,当您启动应用程序时,您可以进行“假”调用以在后台创建虚拟报表而不向用户显示任何内容,以便在用户准备创建真实报表时初始化所有必需资源。