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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports Problem

Status
Not open for further replies.

beauj187

Programmer
Joined
Aug 1, 2005
Messages
8
I am very new to the .NET environment, so please take the into account. I have an application that has a list box of about 15 reports. The selected report is going to open in a new window. the code in the new winodw is farely simple:

<body>
<form runat="server" ID="Form1">
<br>
<CR:CrystalReportViewer id="CrystalReportViewer1" AutoDataBind="false" runat="server" Width="1237px" Height="849px" HasCrystalLogo="False">
</CR:CrystalReportViewer>
</form>
</body>

The code behind this is in c#. Here is the code:

using System;
using System.IO;
using System.Data.SqlClient;
using System.Data.Common;
using System.Text;
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.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web.Design;
using ComponentArt.Web.UI;

namespace Newcastle
{
/// <summary>
/// Summary description for beausTest.
/// </summary>
public class beausTest : System.Web.UI.Page
{
// Add namespaces at top.

protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Literal HtmlOutput;
private string sReportName = "";
private string sReportSource ="";

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

//Crystal Report Variables
ReportDocument crReportDocument = new ReportDocument();

TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();

//Crystal Report Properties
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
CrystalDecisions.CrystalReports.Engine.Table crTable;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
sReportName = Request.QueryString["ReportName"];
sReportSource = "C:\\CMS\\UPDS50\\ADS_Reports\\" + sReportName;
//BuildCrystal(sReportSource);


crConnectionInfo.ServerName = "newton";
crConnectionInfo.DatabaseName = "upds";
crConnectionInfo.UserID = "UserID";
crConnectionInfo.Password = "Password";
//ERROR HERE
crDatabase = crReportDocument.Database;
//
crTables = crDatabase.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

CrystalReportViewer1.ReportSource = crReportDocument;
}

private void BuildCrystal(string sReportName)
{
CrystalReportViewer1.ReportSource = sReportName;
CrystalReportViewer1.Visible = true;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();
}

protected void Output_OnClick(Object sender, EventArgs e)
{

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

I am getting an error here:
crDatabase = crReportDocument.Database;
The runtime error says invalid report file path. But when I run it in Debug mode, crReportDocument.Database there is an error: an exception of type: {CrystalDecisions.CrystalReports.Engine.LoadSaveReportException} occured.
Does anyone have an help or clues?
Thanks in advance.
 
For ASP.NET issues, you might try forum855.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top