导出水晶报告时无法打开连接

时间:2017-01-26 20:46:05

标签: asp.net vb.net crystal-reports

我正在尝试将我的水晶报告导出为pdf,但仍然遇到“无法打开连接”错误。似乎错误发生在CR.Export行。我已经尝试了一切,但不知道如何解决它。仅供参考,它正在我的开发服务器上运行,但当我将其复制到生产服务器时,我收到错误。因此,很难确定它发生的位置。

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    Try

        InitializeComponent()
        strPermitNo = Session("RecordID")
        SpWithViewer(strPermitNo)
        CrystalReportViewer2.DataBind()

    Catch er As Exception
        LogError(er.ToString, "PageInit-PrintPermit1.aspx")
        Exit Try
    Finally

    End Try

End Sub

` Protected Sub btnExport_Click(sender as Object,e As EventArgs)处理btnExport.Click

    strPermitNo = Session("RecordID")

    Try

        Dim CrExportOptions As ExportOptions

        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()

        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()

        CrDiskFileDestinationOptions.DiskFileName = "\\idsfmsrvr\wwwroot\FWPDFs\" & strPermitNo & ".pdf"

        strAttachment = "\\idsfmsrvr\wwwroot\FWPDFs\" & strPermitNo & ".pdf"

        Session("Attachment") = strAttachment

        CrExportOptions = CR.ExportOptions

        If True Then
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
            CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
            CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions

            CrExportOptions.FormatOptions = CrFormatTypeOptions

        End If
        CR.Export()
        EmailPermitToApplicant()
        File.Delete(strAttachment)
        lblMsg.Text = "Permit has been emailed to applicant."
        lblMsg.Visible = True

    Catch er As Exception
        LogError(er.ToString, "btnExport()-PrintPermit1.aspx")
        Exit Try
    Finally
        connFTS.Close()
    End Try`

1 个答案:

答案 0 :(得分:0)

只需一步:

  
      
  1. 首先打开报告,然后按此link
  2.   
  3. 随意出口。
  4.   

请注意:如果您不想显示报告,可以隐藏表单。

祝你好运!