Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

If the crystal report is fully created you could simple use a crystal report viewer which you can drag on to you form and then set the datasource to your report and databind the report to the viewer. Alternatively, you could have your report open as a .pdf file here is the code to do that:

Dim oRpt As New rptMembers 'replace rptMembers with the actual name of your report.
       
       Try 'The following try catch statement is responsible for generating the report in a .pdf format.
           Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
           crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
           crLogonInfo.ConnectionInfo.ServerName = "localhost"
           crLogonInfo.ConnectionInfo.UserID = "sa"
           crLogonInfo.ConnectionInfo.Password = "231168"
           oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)

           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

           With myExportOptions
               .DestinationOptions = myDiskFilesDestinationOptions
               .ExportDestinationType = .ExportDestinationType.DiskFile
               .ExportFormatType = .ExportFormatType.PortableDocFormat
           End With

           oRpt.Export()

           Response.ClearContent()
           Response.ClearHeaders()
           Response.ContentType = "application/pdf"
           Response.WriteFile(myExportFile)
           Response.Flush()
           Response.Close()

           System.IO.File.Delete(myExportFile)
       Catch
       End Try

 

Hope that works!

 

Personally, I find that the .Pdf is easier to work with.

 

Mike55.

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...