Crystal Reports我收到“Load Report Failed”错误?

时间:2015-06-22 18:23:27

标签: sql vb.net crystal-reports

这是我的水晶报告代码:

authorization --- Bearer c2b75b5a-c026-4e07-b8b9-81e9162c9277
x-forwarded-host --- localhost:9000
x-forwarded-prefix --- /example-application

我在行

上收到错误“加载报告失败”
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Dim SqlConn As New SqlConnection("Data Source=classified; Database= classified; User Id= classified; password= classified")
    Dim value As String = My.Application.Info.DirectoryPath
    Dim path As String = "H:\Auto Dealer Project\Public"

    ' Determine whether the directory exists. 

    If Directory.Exists(path) Then
        Console.WriteLine("That specified path exists already.")
    End If
    Dim dirpath As DirectoryInfo = Directory.CreateDirectory(path)
    Console.WriteLine("Temp directory was created:", Directory.GetCreationTime(path))
    ' To load the crystal report in to the report document

    cryRpt.Load(My.Application.Info.DirectoryPath & "\CrystalExport.pdf")

    MessageBox.Show(My.Application.Info.DirectoryPath, path)

    ' to update the cystal report

    cryRpt.Refresh()
    Try
        Dim CrExportOptions As ExportOptions
        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
        CrDiskFileDestinationOptions.DiskFileName = "H:\Auto Dealer Project\Public\CrystalExport.pdf"
        CrExportOptions = cryRpt.ExportOptions
        With CrExportOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
            .DestinationOptions = CrDiskFileDestinationOptions
            .FormatOptions = CrFormatTypeOptions
        End With
        cryRpt.Export()
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try

End Sub

对我而言,这可能只是我做了一些愚蠢的事情,但你有什么建议?

1 个答案:

答案 0 :(得分:1)

您可以在此代码顶部设置路径

Dim path As String = "H:\Auto Dealer Project\Public"

然后以不同的方式查找您的报告。

您确定路径My.Application.Info.DirectoryPath& " \ CrystalExport.pdf"实际上会引导你认为它的作用吗?

在该线上放置一个断点并确保路径指向正确的位置。通常,如果报告不存在,则会收到加载报告错误(因为它不在您认为的文件夹中)