停止运行的程序会导致使用Crystal Report XI Chart Report挂起IDE。

时间:2018-12-06 02:39:50

标签: crystal-reports vb6 crystal-reports-xi

我使用CR XI创建图表报告。当我尝试使用带有此代码的Crystal Report Viewer从vb6运行它时,效果很好:

Public Function prnView(ByVal rptPath As String, ByVal tblName As String, ByVal whereCondition As String, _
    Optional paramPeriod As String = "", Optional sParam As String) As Boolean


Dim vApp As New CRAXDRT.Application
Dim vRpt As New CRAXDRT.Report

Dim arTbl() As String
Dim i As Integer, j As Integer

    Screen.MousePointer = vbHourglass

    Set vRpt = vApp.OpenReport(rptPath)
    With vRpt
        .DiscardSavedData
        arTbl = Split(tblName, "|")
        Dim ConnectionInfo As CRAXDRT.ConnectionProperties
        For i = 0 To .Database.Tables.Count - 1
            Set ConnectionInfo = .Database.Tables(i + 1).ConnectionProperties
            .Database.Tables(i + 1).ConnectionProperties.Item("Connection String") = "DRIVER={mySQL ODBC 5.1 Driver};UID=" & defUser & ";PWD=" & defPass & ";Server=" & serverName & ";port=" & defPort & ";Database=" & defDB
            .Database.Tables(i + 1).ConnectionProperties.Item("User ID") = defUser '"ztech"
            .Database.Tables(i + 1).ConnectionProperties.Item("Server") = serverName ' "192.168.1.253"
            .Database.Tables(i + 1).ConnectionProperties.Item("Database") = defDB 'vDB ' "192.168.1.253"
            .Database.Tables(i + 1).ConnectionProperties.Item("Use DSN Default Properties") = "False"
        Next
        .ParameterFields(1).ClearCurrentValueAndRange
        .ParameterFields(2).ClearCurrentValueAndRange

        .ParameterFields(1).AddCurrentValue dtpFrom.Year
        .ParameterFields(2).AddCurrentValue locSearchID

'        If .ParameterFields.Count > 0 Then
'            arTbl = Split(sParam, "|")
'            For j = 1 To .ParameterFields.Count
'                .ParameterFields(j).ClearCurrentValueAndRange
'                If .ParameterFields(j).ValueType = crNumberField Then
'                    .ParameterFields(j).AddCurrentValue CInt(arTbl(j - 1))
'                ElseIf .ParameterFields(j).ValueType = crStringField Then
'                    .ParameterFields(j).AddCurrentValue arTbl(j - 1)
'                End If
'            Next
'        End If
        If paramPeriod <> "" Then
            For i = 1 To .Sections.Count
                For j = 1 To .Sections(i).ReportObjects.Count
                    If .Sections(i).ReportObjects(j).Name = "strPeriod" Then
                        .Sections(i).ReportObjects("strPeriod").SetText paramPeriod
                    End If
                Next
            Next
        End If
    End With
    crView.ReportSource = vRpt
    crView.EnableGroupTree = False
    crView.Refresh
    crView.ViewReport
    Screen.MousePointer = vbDefault

    Set vApp = Nothing
    Set vRpt = Nothing
End Function

现在的问题是,当我试图“停止”我的项目使其始终挂起,然后VB6 IDE变为“无响应”时,如果我不打开图表报告,我可以“停止”我的项目。

这是我的项目参考,以防我错过了一些在vb6中运行CR图表报告的参考:

  1. Crystal ActiveX报表查看器库11.5
  2. Crystal Reports ActiveX Designer运行时库11.5

0 个答案:

没有答案