【问题标题】:VB.net error (Load Report Failed) When RPT file being open in Crystal Reports designerVB.net 错误(加载报告失败)在 Crystal Reports 设计器中打开 RPT 文件时
【发布时间】:2016-07-13 09:53:22
【问题描述】:

我使用 VB.net 2010 和 Crystal Report XI。 我想在报表查看器中加载报表,但是当我在水晶报表设计器中打开 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。

【问题讨论】:

    标签: vb.net crystal-reports


    【解决方案1】:

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

    这个是具体的:

    <pre>
        Report.Load(reportLocation & filename)
    
    
    
        check it using string variable like this;
         string getpath = reportLocation & filename;
    
        just check it if its location is the same by checking getpath variable
    
    
    
       secondly: crystal report need to login to your working database thats why it says load report failed.
    
    
    
    
      if this one working well then you dont have any problem regarding the     crystal report path:
    
         tbs = Report.Database.Tables
        For Each tb In Report.Database.Tables
            tb.ApplyLogOnInfo(li)
        Next
    
    </pre>
    

    【讨论】:

    • 我有双重检查,三重检查和不止多重检查,报告存在于该路径中。
    • 我确定声明方法不适用于 vb.net,因为它会给出错误,但我已经检查了另一种使用立即数的方法,并且我确定结果与报告的地方完全相同文件放置。
    【解决方案2】:

    我决定回到 Windows 7,在 win 7 中我没有遇到任何这些问题。 也许它更像是兼容性问题或其他东西。 所以我认为,案件已结案。

    【讨论】:

      【解决方案3】:

      转到水晶报表的属性,然后在复制到输出目录下选择始终复制

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2013-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 1970-01-01
      • 2015-01-22
      • 1970-01-01
      相关资源
      最近更新 更多