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

Name the two main parts of .net?

0 Answers  


There are three versions of VB6--Learning Edition, Professional and Enterprise. Is VB.Net similar?

1 Answers  


Can you please explain the difference between thread and process?

0 Answers  


hi dear ? MY problem is that i m developing software for Library. and i want to connect a third party software with my VB.net program in order to calculate DDC number.I dont know how to do this if any body can help me please?

1 Answers  


How to create a constant in vb.net?

0 Answers  






Explain about the keyword must inherit?

0 Answers  


What is pre-jit?

0 Answers  


What is an arraylist?

0 Answers  


What is datatype conversion?

0 Answers  


what are the difference between An input box and Message box ..?

6 Answers   CTS, TATA,


sir i want to ask you that how can i fetch or get sql data into texboxes.where i want to show record in specific texboxes related to student information.when i click on button all data show on texboxes when i put id or name plz inform me on my id

1 Answers  


Explain about the ruby interface generator?

0 Answers  


Categories