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
What is the difference between vb 6 and vb.net?
Explain global assembly cache (gac)?
What do you mean by Redim in VB.NET?
What is the feature which is common to all .net languages?
What is the strong name in .net assembly?
What are the different types of Lock available in Visual Basic?
What do you mean by option strict on?
What is the difference between a "jagged array" and multidimensional array" ?can anyone show me it practically ?
How many languages are supported by .net?
Explain public assembly?
Explain the difference between web.config and machine.config and where it will be ?
How to view an assembly?
How do you define a read only property in a class module?
Is vb.net a programming language?
Can you please explain the difference between dataset and datareader?