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.



    mrwoopey wrote:
    > One more thing I forgot to add. The user will select from a list of
    > reports and this report location should be passed to the crystal
    > reports viewer (in a web browser) to display.
    >
    > So, I need to be able to pass this report location to the crystal
    > report viewer's "reportsource," to display the report. Like I said
    > before, I can set the report source at design time but not runtime.
    >
    > Thanks,
    >
    > Phin
    >
    > (mrwoopey) wrote in message
    > news:<
    >> Hi,
    >>
    >> At design time I can point my crystal report object to a
    >> ReportSource
    >> (a .rpt file) via asp.net. I need to change the ReportSource
    >> dynamically, so when a user wants to view a report, I'll
    >> pass the .rpt
    >> file location to the aspx page that has the crytal
    >> reports viewer and
    >> it should display the requested report.
    >>

    > etc..


    --
    Posted via http://web2news.com the faster web2news on the web
     
    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

    "mrwoopey" <> wrote in message
    news:...
    > Thank you for the reply but I am not sure if you understand want I am
    > trying to do.
    >
    > The following link explains how to set the ReportSource at design time
    > for Crystal Reports in asp.net/vb.net:
    >
    > http://www.aspfree.com/authors/jitajay/crystalreport.aspx
    >
    > I can do what the articale explains, setting a reportsource at design
    > time.
    > I need to set reportsource dynamically (at runtime).
    >
    > Here is the webform that has the reportsource with the following code:
    >
    > 'start of code
    > <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
    > Assembly="CrystalDecisions.Web, Version=9.1.3300.0, Culture=neutral,
    > PublicKeyToken=692fbea5521e1304" %>
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="WebForm1.aspx.vb" Inherits="WebReport.WebForm1"%>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>WebForm1</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    > <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body MS_POSITIONING="GridLayout">
    > <form id="Form1" method="post" runat="server">
    > <CR:CrystalReportViewer id=CrystalReportViewer1 style="Z-INDEX:
    > 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
    > Width="1030px" Height="1089px" ReportSource='<%# "C:\Program
    > Files\Microsoft Visual Studio .NET\Crystal
    > Reports\Samples\Reports\General
    > Business\041603080548CPTAnalysisDrillDownDOE.rpt" %>'
    > DisplayGroupTree="False" BestFitPage="False">
    > </CR:CrystalReportViewer>
    > </form>
    > </body>
    > </HTML>
    > 'end of code
    >
    > I can't pass a report location to the reportsource to this page at
    > runtime. If you have done this or know how to do this please let me
    > know.
    >
    > Thanks!
    >
    > Phin
    >
    > "kota" <> wrote in message

    news:<>...
    > > Use viewer.reportsource="complee phical path" like "D:/test.rpt"
    > >
    > > I hope this may help you.
    > >
    > > Kota.
    > >
    > >
    > >
    > > mrwoopey wrote:
    > > > One more thing I forgot to add. The user will select from a list of
    > > > reports and this report location should be passed to the crystal
    > > > reports viewer (in a web browser) to display.
    > > >
    > > > So, I need to be able to pass this report location to the crystal
    > > > report viewer's "reportsource," to display the report. Like I said
    > > > before, I can set the report source at design time but not runtime.
    > > >
    > > > Thanks,
    > > >
    > > > Phin
    > > >
    > > > (mrwoopey) wrote in message
    > > > news:<
    > > >> Hi,
    > > >>
    > > >> At design time I can point my crystal report object to a
    > > >> ReportSource
    > > >> (a .rpt file) via asp.net. I need to change the ReportSource
    > > >> dynamically, so when a user wants to view a report, I'll
    > > >> pass the .rpt
    > > >> file location to the aspx page that has the crytal
    > > >> reports viewer and
    > > >> it should display the requested report.
    > > >>
    > > > etc..
     
    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

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.
Similar Threads
  1. Alexander
    Replies:
    2
    Views:
    928
    mrwoopey
    Jul 3, 2003
  2. Aaron Ackerman
    Replies:
    1
    Views:
    5,955
    Aaron Ackerman
    Feb 16, 2004
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    0
    Views:
    736
    =?Utf-8?B?ZGF2aWQ=?=
    Jun 23, 2005
  4. sam
    Replies:
    1
    Views:
    3,430
    Richard Myers
    Jul 12, 2005
  5. Learner
    Replies:
    1
    Views:
    1,546
    Richard Dudley
    Jan 11, 2006
  6. anshu
    Replies:
    0
    Views:
    708
    anshu
    Aug 31, 2006
  7. Aaron Ackerman
    Replies:
    1
    Views:
    635
    Aaron Ackerman
    Feb 16, 2004
  8. Comfort
    Replies:
    0
    Views:
    1,060
    Comfort
    Oct 18, 2004
Loading...