Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

I am after creating a report in crystal 11 (trial version), I have unticked the option that saves the data with the report. I am trying to load the report using the code that I have used with crystal reports generated in visual studio.net. My problem is that the report is loading blank, what am I doing wrong?

 

Here is the code that I am using:

 Private Sub GenerateReport()

       Dim crystalServer As String = ConfigurationManager.ConnectionStrings("SERVER").ToString
       Dim count As Int16 = 0

start:
       oRpt = New ReportDocument
       Dim util As New Utility
       Dim rptPath As String = Nothing
       Dim requestedHostAddress As String
       requestedHostAddress = Request.UserHostAddress

       'Get Report path
       rptPath = Server.MapPath("rptMembers.rpt")
       'check the exitence of the file
       If Len(rptPath) = 0 Then
           Exit Sub
       End If
       oRpt.Load(rptPath)
   
       oRpt.DataDefinition.FormulaFields("Org").Text = "'" + Session("OrgID") + "'"
       oRpt.DataDefinition.FormulaFields("Active").Text = "'" + Request.QueryString("Active") + "'"
       oRpt.DataDefinition.FormulaFields("User").Text = "'" + Request.QueryString("by").Replace("'", "`") + "'"
       Try
           ' Generate report  and Export as PDF file
           Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
           crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
           crLogonInfo.ConnectionInfo.ServerName = crystalServer
           crLogonInfo.ConnectionInfo.DatabaseName = ConfigurationManager.ConnectionStrings("DBNAME").ToString
           crLogonInfo.ConnectionInfo.UserID = ConfigurationManager.ConnectionStrings("USER").ToString
           crLogonInfo.ConnectionInfo.Password = ConfigurationManager.ConnectionStrings("PASS").ToString
           oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)

           ' Varables here are used to export the report to PDF
           Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
           Dim myDiskFilesDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
           Dim myExportFile As String

           myExportFile = "C:\temp\PDF " & Session.SessionID.ToString & ".pdf"
           myDiskFilesDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
           myDiskFilesDestinationOptions.DiskFileName = myExportFile
           myExportOptions = oRpt.ExportOptions

           ' Proceed with the Export
           With myExportOptions
               .DestinationOptions = myDiskFilesDestinationOptions
               .ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
               .ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
           End With

           oRpt.Export()

           ' Clean up resources used
           Response.ClearContent()
           Response.ClearHeaders()
           Response.ContentType = "application/pdf"
           Response.WriteFile(myExportFile)
           Response.Flush()
           Response.Close()

           ' Delete the temporary file
           System.IO.File.Delete(myExportFile)

       Catch ex As Exception
           oRpt.Dispose()
           If count <= 1 Then
               crystalServer = ConfigurationManager.ConnectionStrings("SERVER_FAILOVER").ToString
               count = +1
           End If
           GoTo start
       End Try
   End Sub

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Issue solved.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...