【问题标题】:Crystal report Load Report Failed in vb.net after copying a report复制报表后,水晶报表在 vb.net 中加载报表失败
【发布时间】:2014-06-03 11:08:23
【问题描述】:

我有 2 份原始报告: offset.rpt 和 roto.rpt

我需要为这两个报告创建一个新设计(放置新徽标和更改颜色)。 我复制offset.rpt并将其命名为offset_temp.rpt,我复制roto.rpt并将其命名为roto_temp.rpt

这是我的代码:

Public Sub ViewReport()
    Dim i As Integer
    i = Main.dgvColorTolerance.CurrentRow.Index
    Dim filePath As String
    If Main.Process = "ROTO" Then
        filePath = Application.StartupPath + "\roto.rpt"
        If Main.lblcheckuni.Text.Contains("NEW") Then
            filePath = Application.StartupPath + "\roto_temp.rpt"
        End If
    Else
        filePath = Application.StartupPath + "\offset.rpt"
        If Main.lblcheckuni.Text.Contains("NEW") Then
            filePath = Application.StartupPath + "\offset_temp.rpt"
        End If
    End If


    cryRpt.Load(filePath)
    cryRpt.RecordSelectionFormula = " ({command.ID} = " & Main.dgvColorTolerance.Item(Main.dgvColorTolerance.Columns.Count - 1, i).Value & ")"
    cryRpt.SetDatabaseLogon("sa_connection", "******")
    CrystalReportViewer1.ReportSource = cryRpt
    CrystalReportViewer1.RefreshReport()
    CrystalReportViewer1.Zoom(85)

当我运行它时:当 lblcheckuni.text 包含“NEW”时出现错误消息“Load Report Failed”,但如果不是,它运行良好。 我用谷歌搜索,有人说可能文件不存在。但它是存在的。 请帮忙。谢谢

【问题讨论】:

  • 尝试停止 If Main.lblcheckunit... 行,然后单步执行代码。它是否放入 if 语句并尝试将 _temp.rpt 分配给 filePath 变量?
  • 我看到了我的问题@APrough,路径错误,你能帮我看看路径的语法吗?路径是 C:\Documents and Settings\administrator\Desktop\color_tolerance\ColorTolerance (Win App)\ColorTolerance\roto_temp.rpt 如果我放置整个路径,不推荐它,对吗?这条路径的快捷方式是什么语法,所以我每次在每个本地运行这个程序时都不需要编辑路径。谢谢
  • 也许做 Environment.GetFolderPath(Environment.SpecialFolder.Desktop) 来获取桌面路径并将其余部分构建到它上面?

标签: asp.net vb.net reporting-services crystal-reports crystal-reports-xi


【解决方案1】:

获取桌面路径

Dim desktop as string = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
filePath = desktop & "\color_tolerance\ColorTolerance (Win App)\ColorTolerance\" & reportName

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多