views:

1738

answers:

4

How to use crystal Reports with ASP.Net 2.0. Any Samples/Tutorials/Examples which shows how to deploy Crystal Reports on a production Server.

A: 

Theres about 3,000,000 samples on both MSDN and Business Objects Web sites + many others.......

Is there something specific you are having trouble with?

Adrian
+4  A: 

Having just been through the pain of this myself, here's a couple of pointers that will hopefully save you time...

Crystal Reports on MSDN - lots of good stuff in here

Which Persistence Approach Should I Use with Crystal Reports - gives detail and code samples on how best to control the lifesycle of a report object

This post also gives some good advice around the report object lifecycle

Deployment... The latest Crystal Reports runtimes don't run in a 64 bit environment, so if deploying to a 64 bit server you will either have to configure IIS to run an 32 bit mode, or use a previous version of the runtime. I have had the most luck with the runtime that is distributed with VS2008, this can be found in

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5

I note you are using ASP.NET 2.0 - i'm sure there is a VS2005 equivalent runtime. Try and get the deployment environment working early on in the project, as it will no doubt cause more headaches than you expect.

Finally, one last point that has cost us some time and is worth mentioning - the standard parameters screen in Crystal Reports will only take you so far. If you want to get complex with how you present your parameters to the user (e.g. by having a parameters dependent on the selection of another parameter) you will need to roll your own parameter screens. This is fairly easy as the object model gives you access to all the info you will need about parameters. We have gone down the route of creating a generic parameters screen that builds itself according to the parameters found in the report it is pointed at.

Paul Nearney
A: 

This is the code I generally use:

'Generate the Report
Dim oRpt As New ReportDocument
Dim reportPath As String = Server.MapPath("crtTAL.rpt")
oRpt.Load(reportPath)

oRpt.SetDataSource(dsTAL)

If Not IO.Directory.Exists(tempLocation) Then
    IO.Directory.CreateDirectory(tempLocation)
End If

If IO.File.Exists(tempLocation & filename) Then
    IO.File.Delete(tempLocation & filename)
End If

' ********************************

' First we must create a new instance of the diskfiledestinationoptions class and
' set variable called crExportOptions to the exportoptions class of the reportdocument.
Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim crExportOptions As ExportOptions = oRpt.ExportOptions

'Export to Word

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = tempLocation + filename

'set the required report ExportOptions properties
With crExportOptions
    .DestinationOptions = crDiskFileDestinationOptions
    .ExportDestinationType = ExportDestinationType.DiskFile
    .ExportFormatType = ExportFormatType.WordForWindows
End With

'Once the export options have been set for the report, the report can be exported. The Export command
'does not take any arguments
Try
    ' Export the report
    oRpt.Export()
    oRpt.Close()
    oRpt.Dispose()
    projectCount = projectCount + 1
Catch err As Exception
    Response.Write("<BR>")
    Response.Write(err.Message.ToString)
    errorList = errorList & dtrProjects.Item("Title") & "; "
End Try
SchwartzE
A: 

Thats what I use usually,Asp.net/C#

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        ///create instance of class first
        ReportDocument rpDoc = new ReportDocument();
        ///load the report
        rpDoc.Load(@"TicketingBasic.rpt");

        ///pass the report to method for dataInfo
        getDBInfo(rpDoc);
        /// et the source for report to be displayed
        CrystalReportViewer1.ReportSource = rpDoc;
    }

    protected static void getDBInfo(ReportDocument rpDoc)
    {
        ///Connection Onject
        ConnectionInfo cn = new ConnectionInfo();
        ///DataBase,Table, and Table Logon Info
        Database db;
        Tables tbl;
        TableLogOnInfo tblLOI;

        ///Connection Declaration
        cn.ServerName = "??????";
        cn.DatabaseName = "???????";
        cn.UserID = "???????";
        cn.Password = "????????";

        //table info getting from report
        db = rpDoc.Database;
        tbl = db.Tables;

        ///for each loop for all tables to be applied the connection info to
        foreach (Table table in tbl)
        {
            tblLOI = table.LogOnInfo;
            tblLOI.ConnectionInfo = cn;
            table.ApplyLogOnInfo(tblLOI);
            table.Location = "DBO." + table.Location.Substring(table.Location.LastIndexOf(".") + 1);

        }

        db.Dispose();
        tbl.Dispose();
    }

and on Aspx side:

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