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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Before in my vb app I would just load the icons from dll. How can I load the icons provided by .net dynamically?

521


How to connect crystal report in vb.net ?

573


Name some different types of control?

531


What is jagged array in vb.net?

637


what is common language specification?

517






What is the difference between manifest and metadata?

550


What is late binding and early binding?

556


How many classes a dll can contain?

554


Name a feature which is common to all .net languages?

581


What is the use of internal keyword?

574


List the different types of assembly?

548


What are the difference between dispose(), close(), exit(), end()? When do we use them?

537


What are the parts of the visual basic control?

536


What are the various open source tool available for VB.NET?

564


Explain the advantages of migrating to vb.net?

507