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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / howard rothenburg

Try:

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

Public Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles LinkButton1.Click

OpenPDF(Request.ApplicationPath + "/Reports/Report.pdf")

End Sub


Private Sub OpenPDF(downloadAsFilename As String)
Dim RptDoc As New ReportDocument()
RptDoc.Load(Server.MapPath(Request.ApplicationPath + "/Reports/myreport.rpt"))
RptDoc.SetDatabaseLogon("user", "password", "server", "database")

Dim stream As New BinaryReader(RptDoc.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", Convert.ToString("attachment; filename=") & downloadAsFilename)
Response.AddHeader("content-length", stream.BaseStream.Length.ToString())
Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)))
Response.Flush()
Response.Close()
End Sub
End Class

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More VB.NET Interview Questions

What are all the parts of .net framework?

0 Answers  


Using VB, how can you change the Mouse Pointer?

0 Answers   CGI,


Explain private assembly?

0 Answers  


What is difference between metadata and manifest?

0 Answers  


What is the Difference between Overriding and overloading?

31 Answers   Subex, TCS,






hello dear friends my problem is that i want to save images that is pictures in SQL server using vb.net can any body help me to do so please

1 Answers  


What is tracing?

0 Answers  


what are the types of threading models in VB.net ?

1 Answers   Satyam,


Name the tool which can convert visual basic old version to .net compatibility version?

0 Answers  


List the types of authentication?

0 Answers  


What is multiple form in vb?

0 Answers  


What is strong typing and weak typing?

0 Answers  


Categories