Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visual studio.net crystal reports

Status
Not open for further replies.

aspnetuser

Technical User
Sep 9, 2004
273
0
0
US
Hello,
I have been using CR and CE version 8.5 and 8.0 for a few years now. CE is really easy to upload and display reports for all my users. I recently purchased Visual Studio.NET. I see their is a crystal reports addin to the software. I am try to develop a .aspx page that will display a crystal report similar to Crystal enterprise for various users.

How do this work? I have VS.net loaded on my client machine. The CE I work with is on a web server that I have full access to. I created a folder on the webservers inetpub and started a new project. Not sure how to do the rest and wanted to know the pros and cons verses buying more enterprise CALS since they are so expensive.

Can users run these aspx crystal report web pages on their browsers if they don't have CR 8.5 installed etc...

Please advise.
Regards.
 
not sure. I will look into it. i really appreciate your help and patience. I will pick the up again later tonight.

I will post back and again thanks so much for your knowlegdge...
Regards,
 
I can't figure out how to lead the samples to test all of this?

Any other easy ways i could cut and paste files just to test if it works?

 
How simple should it be, just to get the report to display in the viewer or you need to manipulate with report selection formula, parameters, etc.?

1. In IIS, make sure you have a virtual directory in the
root of your site, called CrystalReportWebFormViewer2,
pointing to
<Drive>:\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports\Viewers\
physical directory

2. In your project, add references to
CrystalDecisions.CrystalReports.Engine.dll
CrystalDecisions.Shared.dll
CrystalDecisions.Web.dll.
Then add a web form WebForm1 to the root of the project.

3. Right click on the toolbar, select "Add/Remove Items";
in the ".Net Framework Components" tab, check
CrystalReportViewer, namespace CrystalDecisions.Web,
assembly CrystalDecisions.Web(9.1.9800.0) (since you are
on Framework 1.1 and have no Crystal 9 installed).
Click OK to exit the dialog.

4. From the toolbar, drar the CrystalViewer control on the
form. You should see something like this:
Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="MyProject.WebForm1" %>
<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=9.1.9800.0, Culture=neutral, PublicKeyToken=<some key>" %>

<HTML>
  <HEAD>
    <title>WebForm1</title>
  </HEAD>
  <body>	
    <form id="Form1" method="post" runat="server">
<CR:CrystalReportViewer id=CrystalReportViewer1 runat="server"></CR:CrystalReportViewer>
    </form>	
  </body>
</HTML>

5. Page code behind:
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;

namespace MyProject.WebForm1
{	
  public class WebForm1: System.Web.UI.Page
  {
    protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
	
  private void Page_Load(object sender, System.EventArgs e)
  {
    try
    {
        // physical location of the rpt file
        string reportPath = "C:\\Reports\\MyReport.rpt";

        // 1. point report to the viewer
        CrystalReportViewer1.ReportSource = reportPath;	

        // 2. or by using the ReportDocument object
        // ReportDocument doc = new ReportDocument();
        // doc.Load(reportPath);
        //CrystalReportViewer1.ReportSource = doc; 
      
    }
    catch(Exception ex)
    {
      Response.Write(ex.Message);
    }
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {			
    InitializeComponent();
    base.OnInit(e);
  }
		
  private void InitializeComponent()
  {    
    this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}

This is the simpliest way to just display the report; the report selection formula and parameter values can be set through CrystalReportViewer object. If you need to switch databases or work dynamicaly with report layout, then you need to use ReportDocument object. BTW, there is a couple of great Crystal forums on this site:
forum149
forum766
forum767
 
I know there is a cheap piece of software that you can buy from that will allow you to view an already developed crystal report without a Crystal license. This works with any database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top