0

I am using this code to show the report

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()

but it's too slow to show the report in the first time. When I try to run it again without closing the window it work perfectly. Is there any way to make it faster?

Thanks

4

1 回答 1

0

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

于 2012-09-27T19:43:44.230 回答