how to create crystal reports in asp.net & vb.net with
syntax

Answer Posted / ranjith reddy

First create crystal report.In the interface of report i.e
aspx form to display report,add report document as
Toolbox-->Components-->ReportDocument.
Call the sub routine CreatePDF to display report.
rptProduct is the name of crystal report and docProd is the
name of report document.




Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()
'start - This code should be pasted under #Region
Private Sub itializeComponent()
'rptProduct is the name of crystal report.
Me.docProd = New rptProduct
'
'docProd
'
Me.docProd.PrintOptions.PaperOrientation =
CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation
Me.docProd.PrintOptions.PaperSize =
CrystalDecisions.Shared.PaperSize.DefaultPaperSize
Me.docProd.PrintOptions.PaperSource =
CrystalDecisions.Shared.PaperSource.Upper
Me.docProd.PrintOptions.PrinterDuplex =
CrystalDecisions.Shared.PrinterDuplex.Default
'Ends here

'Declaration of report document
Protected WithEvents docProd As rptProduct

Private Sub CreatePDF()
Dim objDS As New DataSet
Dim dfdoFile As New
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim strServerPath As String
Dim szFileName As String


'Create dataset as per requirement

docProd.SetDataSource(objDS.Tables(0))

szFileName = Session.SessionID & ".pdf"
' rptDailyCalls.pdf
strServerPath = MapPath("~") & "\Report\"
' Here the pdf file will be saved.
File.Delete(strServerPath & "\" &
szFileName) ' Delete file first
dfdoFile.DiskFileName = strServerPath & "\" &
szFileName
With docProd
.ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile
.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
.ExportOptions.DestinationOptions = dfdoFile
.Export()
End With
'URL of the pdf file
Response.Redirect("http://localhost/WebApplication1/" &
szFileName ,Flase)
End Sub

Is This Answer Correct ?    7 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Using VB, how can you change the Mouse Pointer?

638


What is an application domain? how they get created?

583


What do you mean by serialization and deserialization?

544


Describe about visual basic.net?

559


What is the difference between custom control and user control?

552






What is globalization?

553


Define serialization in .net?

639


What is the purpose of objects present in asp.net?

576


What are the two main parts of .net?

568


What do you mean by deserialization?

556


What are jagged arrays ?

574


What is the differnce between managed code and unmanaged code?

541


Described strong typing

573


source code for how to login a vb.net application ?

595


Tell me which namespace are used for accessing the data?

523