how to create crystal reports in asp.net & vb.net with
syntax
Answers were Sorted based on User's Feedback
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 |
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 |
What are the difference between dispose(), close(), exit(), end()?
Using VB, how can you change the Mouse Pointer?
What are the two main parts of .net?
Explain trace in vb.net?
What are the objects in asp.net and tell the purpose of those objects
how to restore database using vb.net?
4 Answers Eclat, PCS, Pepon, Restor, TCS,
What is the differences between dataset.clone and dataset.copy?
ColumnMapping belongs to which namespaces?
what do you mean by .Net Framework
17 Answers Assurgent, College School Exams Tests, Guru Tech, Krishna Infotech, Ksb, Microsoft,
What is non_deterministic finalization?
Explain the difference between system.string and system.stringbuilder classes?
Explain an assembly and its use?