Re: Changing Crystal Report ReportSource dynamically via asp.net

Discussion in 'ASP .Net' started by kota, Jun 24, 2003.

  1. kota

    kota Guest

    Use viewer.reportsource="complee phical path" like "D:/test.rpt"

    I hope this may help you.

    Kota.
     
    kota, Jun 24, 2003
    #1
    1. Advertisements

  2. hi mrwoopey

    check the below i think this is what u r looking for
    public ReportDocument oRpt=new ReportDocument();

    // write a if condition to check the selection

    string str=Server.MapPath(report Name);
    string str1=str.Replace("\\", \\\\);
    oRpt.Load(str1);

    //you have to pass the logon parameters for the report
    CrystalDecisions.Shared.TableLogOnInfo crLogonInfo;
    crLogonInfo = oRpt.Database.Tables[0].LogOnInfo;
    crLogonInfo.ConnectionInfo.ServerName = Session["Server"].ToString().Trim();
    crLogonInfo.ConnectionInfo.UserID =Session["dbUser"].ToString().Trim();
    crLogonInfo.ConnectionInfo.Password =Session["dbPwd"].ToString();
    crLogonInfo.ConnectionInfo.DatabaseName
    =Session["dbName"].ToString().Trim();
    oRpt.Database.Tables[0].ApplyLogOnInfo(crLogonInfo);

    CrystalReportViewer1.DataBind();

    CrystalReportViewer1.ReportSource = oRpt;


    huzaifa
     
    Huzaifa Matawala, Jun 27, 2003
    #2
    1. Advertisements

  3. kota

    mrwoopey Guest

    Huzaifa,

    I'll try your solution also! Thanks!

    Phin
     
    mrwoopey, Jul 1, 2003
    #3
  4. kota

    Howard Rothenburg

    Joined:
    Oct 26, 2014
    Messages:
    1
    Likes Received:
    0
    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
     
    Howard Rothenburg, Oct 26, 2014
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.