Professional Web Applications Themes

Changing Crystal Report ReportSource dynamically via asp.net - ASP.NET General

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 > ...

  1. #1

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    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
    >
    > [email]mrwoopey[/email] (mrwoopey) wrote in message
    > news:<e48ab325.0306231004.3dbf1a39posting.google. com
    >> 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 [url]http://web2news.com[/url] the faster web2news on the web
    kota Guest

  2. #2

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    Here is a good source of info on your topic:

    [url]http://www.crystaldecisions.com/products/dev_zone/downloads/wrox4_report_integration_web.pdf[/url]

    To select report at runtime you may use switch statement like this:

    switch(Request["ReportId"])
    {
    case "InvoiceAndPaymentDetail":
    CrystalReportViewer1.ReportSource= invoiceAndPaymentDetail1;
    break;
    case "PaymentHistory":
    CrystalReportViewer1.ReportSource= paymentHistory1;
    break;
    case "FailedPayments":
    CrystalReportViewer1.ReportSource= failedPayments1;
    break;
    }
    This routine is best to be placed on Init event of the page
    Then you can use querystring to call a particular report using querystring.
    It is not a good Idea to use only postback for navigating to new report,
    because it may cause navigation (through groups in the record) problem. Mean
    if user drilled down, and you are selected different record and post back,
    then Viewer will try to find the same detail group.
    So I found it useful to case redirect to fresh page when selecting different
    report.
    private void DropDownList1_SelectedIndexChanged(object sender,
    System.EventArgs e)
    {
    Response.Redirect("Reports.aspx?ReportId="+DropDow nList1.SelectedItem.Value)
    ;
    }

    Thanks, Alexander



    "mrwoopey" <mrwoopey> wrote in message
    news:e48ab325.0306231437.57516037posting.google.c om...
    > 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
    >
    > [email]mrwoopey[/email] (mrwoopey) wrote in message
    news:<e48ab325.0306231004.3dbf1a39posting.google. com>...
    > > 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.
    > >
    > > Does anybody know how to do this? I understand how it should work but
    > > I can't get it to work. Please post code, links, or ideas on how to do
    > > this.
    > >
    > > Thanks,
    > >
    > > Phin

    Alexander Guest

  3. #3

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    hi mrwoopey

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

    // 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" <mrwoopey> wrote in message
    news:e48ab325.0306241318.5f6ee634posting.google.c om...
    > 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:
    >
    > [url]http://www.aspfree.com/authors/jitajay/crystalreport.aspx[/url]
    >
    > 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\041603080548CPTysisDrillDownDOE.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" <kotarao.news.invalidweb2news.net> wrote in message
    news:<43769N090web2news.com>...
    > > 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
    > > >
    > > > [email]mrwoopey[/email] (mrwoopey) wrote in message
    > > > news:<e48ab325.0306231004.3dbf1a39posting.google. com
    > > >> 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 Guest

  4. #4

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    Alexander,

    Thanks for your reply! I will try it!

    Phin
    mrwoopey Guest

  5. #5

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    Huzaifa,

    I'll try your solution also! Thanks!

    Phin
    mrwoopey Guest

  6. #6

    Default Re: SOLUTION - Changing Crystal Report ReportSource dynamically via asp.net

    OK...

    I got this to work. I am posting this so future "seekers" can use
    this.

    The following steps accepts a crystal report (rpt) location via a
    querystring request ("http://www.somesite.com/?ReportSource=/Reports/Sample.rpt")
    and loads the report into the crystal reports viewer (web):

    1. on the aspx page that has the CrystalReportViewer, add a label
    called lblError and set the Visible attribute to visible =False.

    2. paste the following code into the class:
    -------------------
    Private Sub LoadReport()

    Try
    crvWebReportViewer.ReportSource =
    Server.MapPath(Request("ReportSource"))
    Catch ex As Exception
    lblError.Text = "Error displaying the report: " &
    ex.Message
    lblError.Visible = True
    crvWebReportViewer.Visible = False
    End Try

    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    LoadReport()
    End Sub

    ---------------------------------

    Its rather simple. When the page loads it calls LoadReport which
    requests the querystring of the ReportSource.

    Please note when deploying to a machine other than your dev machine,
    VS.net does not include all the required files in the Setup app. Here
    are the details of the extra files and steps (MSMs along with Crystal
    License code) you need to do to deploy this :

    [url]http://support.crystaldecisions.com/communityCS/TechnicalPapers/crnet_deployment.pdf[/url]

    Enjoy,

    Phin

    PS

    This sample code is provided "as is" without warranty of any kind. You
    are solely responsible for your use of this sample code and for any
    results from your use of this sample code.
    mrwoopey Guest

  7. #7

    Default Re: Changing Crystal Report ReportSource dynamically via asp.net

    you may add those two line when you change report source,

    CrystalReportViewer1.ReportSource="path.rpt";

    CrystalReportViewer1.RefreshReport();

    Yifei

    "mrwoopey" <mrwoopey> wrote in message
    news:e48ab325.0306231437.57516037posting.google.c om...
    > 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
    >
    > [email]mrwoopey[/email] (mrwoopey) wrote in message
    news:<e48ab325.0306231004.3dbf1a39posting.google. com>...
    > > 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.
    > >
    > > Does anybody know how to do this? I understand how it should work but
    > > I can't get it to work. Please post code, links, or ideas on how to do
    > > this.
    > >
    > > Thanks,
    > >
    > > Phin

    Yifei Guest

Similar Threads

  1. ASP .NET - Crystal Report Error
    By douglas in forum ASP Components
    Replies: 0
    Last Post: January 26th, 03:25 PM
  2. How to display Crystal Report
    By Kamal Ahmed in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: July 5th, 02:05 PM
  3. Pls Hlp : crystal report
    By shalit KG in forum ASP Database
    Replies: 4
    Last Post: May 25th, 03:07 PM
  4. Formatting a Crystal Report
    By Kerri in forum ASP
    Replies: 0
    Last Post: September 20th, 06:07 PM
  5. ASP + Crystal Report 9
    By Jason Chan in forum ASP
    Replies: 1
    Last Post: September 19th, 10:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139