繁体   English   中英

Crystal Reports我收到“加载报告失败”错误?

[英]Crystal Reports I get "Load Report Failed' error?

这是我的水晶报表代码:

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

我在行上收到错误“加载报告失败”

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

对我来说,可能只是我在做一些愚蠢的事情,但是您建议什么呢?

您可以像这样在代码的顶部设置路径

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

但然后以另一种方式查找报告。

您确定My.Application.Info.DirectoryPath和“ \\ CrystalExport.pdf”的实际路径指向您认为的位置吗?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM