cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports 2008 and ASP.NET Web Application Deployment - Tipps

Former Member
0 Kudos

Hello all,



The last few days I spent a lot of time trying to integrate a Crystal Report into an ASP.NET Web Application. In this post, I want to pass on some tips and I try to describe how I've achieved it finally to get this thing up and running


================

1. Prerequisites

================


Developer machine:

- Windows 2003 Server with IIS 6

- Visual Studio 2008 Standard Edition

- Crystal Reports 2008 SP2 installed (Full Product Install)

- Crystal Reports 2008 SP2 Runtime installed

- .NET Framework 3.5 SP1 installedv


Deployment machine:

- Windows Server 2008 with IIS 7

- Crystal Reports 2008 SP2 Runtime installed

- .NET Framework 3.5 SP1 installed


As you can see, my developer environment doesn't exactly match my target machine. I think it doesn't matter as long as you're using the same Crystal Report Runtime Version.


===================

2. Steps to Success

===================


Step 1: Create your Report

-

-




Use Crystal Reports Designer 2008 SP2 to generate your Report. Save it as RPT-File.


Step 2: Integrate ReportViewer Control into ASPX-Page

-

-




Open your desired ASPX-File and place the CrystalReportViewer Control on your page.



Here's my code for the CrystalReportViewer control:


<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />


I had to make sure, that the following Assemblies were included in my web project:



- CrystalDecisions.Shared

- CrystalDecisions.Web




The Code-Behind file of my aspx-page looks like this:


    public partial class ShowReport : System.Web.UI.Page<br>
    {<br>
        protected void Page_Init(object sender, EventArgs e)<br>
        {<br>
            ConfigureCrystalReports();<br>
        }<br>
<br><br>
        private void ConfigureCrystalReports()<br>
        {<br>
            string ReportPath = "";<br>
            
            switch (Request.QueryString["id"])<br>
            {<br>
                case "1": ReportPath = Server.MapPath("MyReport1.rpt"); break;<br>
                case "2": ReportPath = Server.MapPath("MyReport2.rpt"); break;<br>
            }<br>
<br><br>
            ConnectionInfo connectionInfo = new ConnectionInfo();<br><br>

            connectionInfo.ServerName = "<your server name here>";        // Host name of database server<br>
            connectionInfo.DatabaseName = "<your database name here>";    // Database name<br>
            connectionInfo.UserID = "<your username here>";               // Username to login into database<br>
            connectionInfo.Password = "<your password here>";             // Password to login into database<br>
            CrystalReportViewer1.ReportSource = ReportPath;<br>
            SetDBLogonForReport(connectionInfo);<br>
        }<br>
<br><br>
        private void SetDBLogonForReport(ConnectionInfo connectionInfo)<br>
        {<br>
            TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;<br>
            foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)<br>
            {<br>
                tableLogOnInfo.ConnectionInfo = connectionInfo;<br>
            }<br>
        }<br>
    }<br>


As you can see, this source reads the id-parameter from the page request variable and then decides which report to load. This code assumes, that your rpt-files are placed in the same location as the aspx-page above. Server.MapPath then maps the website location to an absolute file system location. This is later passed to the viewer control which finally opens the file and renders it.


The code you see above is recommended by the crystal reports people (and is somewhere placed in one of their guides - app developer guide or api guide, I think).


Step 3: Configure IIS

-

-




When you install the Crystal Reports Runtime, you will notice, that a new directory has been created in your C:inetpubwwwrootaspnet_clientsystem_web2_0_50727 directory. This is the code which the CrystalReportViewer control needs in order to properly display the parameter input form and the rendered report.


I had to create a new virtual directory in my app which points to the aspnet_client folder. This is my setup of the virtual directory:


Virtual directory name: aspnet_client

Points to: C:inetpubwwwrootaspnet_client


The structure of your web app including aspnet_client virtual directory has to look like this after setup:


/MyWebApplication<br>
    /bin<br>
    /aspnet_client  --> this is the virtual directory!<br>
    Default.aspx<br>
   Web.config<br>


I also had to remove the web.config file inside the crystalreportviewers12 directory to get my app up and running. I don't know what the purpose of this web config file is. I'm currently investigating it as I've nothing found on the forums here. I would really appreciate it if anyone could point me to another forum thread regarding this topic.



Right, I hope I haven't forgotten anything to mention. Should one have questions I'm glad to help. Just let me know.


Step 4: Deploy your App

-

-




After that, I've deployed the app using the Publish.. function. You have to make sure, that you copy your reports to the same location as your aspx-page after deploying. Unfortunately I haven't worked out a better way to deploy the reports. But maybe anyone can help me here too?


Thank you.

André

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Andre, thank you very much for contributing your knowledge and experience to this forum.

I'd like to add a few links to resources that may also help others.

Notes (Kbases) search page:

https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true

Downloads seach paage (this is a bit messy at this time, but still useful):

https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm

A wiki that lists links to sample apps (VB and C#):

https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples

Crystal Reports For Visual Studio 2005 Walkthroughs (one of my most favorite resources):

http://www.sdn.sap.com/irj/boc/index;jsessionid=(J2EE3414700)ID0521322850DB10695130077163335173End?r...

Basics ot Crystal Reports in VS .NET:

https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/702ab443-6a64-2b10-3683-88eb1c3744bc&overrid...

8CR 2008 developer library:*

http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_dg_12_en.chm

CR 2008 API reference:

http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_apiRef_12_en.chm

Other Developer links:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/e09207de-f67a-2b10-4b90-ef2ea... [original link is broken]

And finally, two documents on how to troubleshoot the CR DHTML viewers when used in .NET web app.

Dynamic images appear as red X on Crystal Reports in VS .NET web viewer:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0437ea8-97d2-2b10-2795-c202a76a...

Viewer toolbar images appear as red u2018X on Crystal Reports VS .NET web viewer:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50aa68c0-82dd-2b10-42bf-e5502b45...

Ludek

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Andre,

I have made some report with crystal report.

In my report, i use dynamic parameter to list all of values from database.

In my development PC, this dynamic parameter worked fine and show all list of values.

After i publish on IIS7, this dynamic parameter does not show anything.

Only some text box, and user must type on it.

Please help me solve this problem.

Regards,

Wahyu

Former Member
0 Kudos

Hi Andre,

I have a problem with the crystal report. I'm using crystal report 12 and created a report with bar charting. Its working fine in my PC but when i deployed it in the server the chart is not displaying, instead a blank image symbol is displaying, what could be the problem and hwo to rectify this, Please help me

former_member183750
Active Contributor
0 Kudos

[This|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0437ea8-97d2-2b10-2795-c202a76a5e80] article should help. Also, don't forget to search the [notes|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true] database for other possible solutions.

Ludek