Sunday, November 11, 2007

Publishing Crystal Reports to web using VS.Net 2005


Publishing Crystal Reports to web using Visual Studio.Net 2005-a walk through



This article gives you a high level walk through for publishing a crystal report on to an ASP.Net web site using Microsoft Visual Studio.Net 2005. It assumes that you have already created a crystal report.

Requirements

  1. A valid crystal report(.rpt file) with its data source set.
  2. VS.Net 2005
  3. Crystal Reports Merge module for VS 2005 (available at http://resources.businessobjects.com/support/communitycs/FilesAndUpdates/cr_net_2005_mergemodules_mlb_x86.zip?recDnlReq=Record&dnlPath=cr_net_2005_mergemodules_mlb_x86.zip) if the link does not exist, then do a search for VS 2005 Merge modules in the businessobjects website.
    1. Unzip the downloaded file
    2. Place the msm file in the folder : Program Files\Common Files\Merge Modules
  4. An assumption is made that the deployment and development is done on a 32Bit x 86 machine.

The walk through

  1. Run Visual Studio.Net 2005
  2. Create a New Website by selecting File>> New>>Website
  3. Select ASP.Net crystal report website from the dialog box and provide the path and filename for the application.(The default path and filename will do for testing purposes) . Click OK.

  1. Select “From an Existing Report” in the Crystal Reports Gallery dialog

  1. Click OK and Select the rpt file in the next dialog box and click open.
  2. Now a visual studio project is open with a default.aspx page and a crystal report in the solution explorer
  3. Add the following code to the code behind page default.aspx.vb

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

CrystalReportViewer1.DataBind()

End Sub

  1. Compile and Run the application to see the report in action
  2. Close the browser window and stop the application

Adding the WebSetup Project

  1. Right click on the solution in the solution explorer and Add a new project

  1. The add new project dialog pops up. On the left pane Select Other Project Types>>Setup and Deployment and on the right pane select Web Setup Project and click OK

  1. Go to the solution explorer. Right click on the web setup project and select ADD>>Project Output

  1. Click Ok on the dialog box

  1. Once again right click on the web setup and select Add>>Merge Module

  1. Select CrystalReportsRedist2005_x86.msm from the dialog box. If the file is not present there please download and copy it to the specified directory. Refer the requirements section at the beginning of the article

  1. Now the solution explorer have the following items under the web setup project

  1. Build the web setup project by right clicking the web setup project and selecting Build

  1. Now you have the setup.exe and the web setup msi in the project path.
  2. Copy them into the server where the application is to be hosted
  3. Run the setup file and continue with the installation wizard.
  4. Now you have successfully installed the web application with a crystal report viewer.

3 comments:

Anonymous said...

worked perfectly, exactly what we needed. Thank you SO Much
-Matt

dd said...

Have you gotten "Unable to connect: incorrect log on parameters."

Or

"Unable to connect: incorrect log on parameters."

errors when your report has multiple pages? This happens when going to the next or last page of the report, though the first page pops up just fine. Any idea? I followed the instructions exactly.

Anonymous said...

You may also want to consider a portal solution like rePORTAL. It lets you quickly and securely publish your Crystal and SSRS reports to the web without any need for coding, and also incorporates a very powerful scheduling engine.