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

Explain an assembly?

0 Answers  


What is redim keyword and its use?

0 Answers  


What is a static class?

0 Answers  


thak you Mr Govind for replying to my question. My next question is that how to retrieve image stored in an SQL server table and assign it to any image control or picture control using VB.net

0 Answers  


how to create views in sql with syntax and example

5 Answers  






Can you please explain the difference between c# and vb.net?

0 Answers  


Explain the difference between vb 6 and vb.net?

0 Answers  


What is difference between import system.data.sqlclient,system.data.oledb?

0 Answers  


hello friends, I have created a animated button in VB.NET. As its dll file coding can be viewed and also copied to some other location. So my question is how can I protect the Dll file of the animated button so that noone can access it. Any idea about this???????? Thanks Rekha

3 Answers  


Explain cls?

0 Answers  


Define clr?

0 Answers  


Explain option strict?

0 Answers  


Categories