p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Professional Crystal Reports for VS.NET (http://p2p.wrox.com/book-professional-crystal-reports-vs-net-45/)
-   -   how to view crystal report in asp.net (http://p2p.wrox.com/book-professional-crystal-reports-vs-net/41759-how-view-crystal-report-asp-net.html)

bhaveshsanghani April 26th, 2006 05:52 AM

how to view crystal report in asp.net
 
how to view crystal report without database password prompting in asp .net 2.0

Bhavesh Sanghani

hrothenb October 26th, 2014 01:10 AM

how to view crystal report in asp.net vb
 
Try:

Code:


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



All times are GMT -4. The time now is 08:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.