VB.net错误(加载报告失败)在Crystal Reports设计器中打开RPT文件时

时间:2016-07-13 09:53:22

标签: vb.net crystal-reports

我使用VB.net 2010和Crystal Report XI。 我想在报表查看器中加载报表,但是当我在crystal reports designer中打开rpt文件时,vb.net中的报表查看器会出错:加载报表失败。

但是当我关闭水晶报告软件或者只是关闭水晶报告软件中的rpt文件时,报告查看器就可以正常运行了。 每次我想从vb.net中的报表查看器打开rpt文件时,是否真的必须关闭水晶报表。

如果需要,这是我的代码:

Dim Report As New ReportDocument
    Dim Report1 As New ReportDocument
    Dim li As New TableLogOnInfo
    Dim tbs As Tables
    Dim tb As Table
    Try
        Report.Load(reportLocation & filename)

        li.ConnectionInfo.DatabaseName = dbname
        li.ConnectionInfo.UserID = userid
        li.ConnectionInfo.Password = password
        li.ConnectionInfo.ServerName = servername

        tbs = Report.Database.Tables
        For Each tb In Report.Database.Tables
            tb.ApplyLogOnInfo(li)
        Next

        Report.RecordSelectionFormula += IIf(Report.RecordSelectionFormula <> "", " and ", "") & formula
        Report.Refresh()
        Report.SetParameterValue(0, param(0))
        Report.SetParameterValue(1, param(1))
        Report.SetParameterValue(2, param(2))
        If param(3) <> "" Then Report.SetParameterValue(3, param(3))

        crV.ReportSource = Report
        crV.Show()
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

如果被问到,我使用的是Windows 10和SQL Server 2008 R2 SP2。

2 个答案:

答案 0 :(得分:0)

检查您的报告路径;这是你的问题。系统无法找到报告存在。

具体来说:

you have specified that the package VirtualBox should be installed, this package doesn't exist

答案 1 :(得分:0)

我决定回到Windows 7,在win 7中我没有遇到任何这些问题。 也许它更像是兼容性问题。 案件我认为,案件结束了。

相关问题