|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Enterprise;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using System.Data.SqlClient;
public partial class CRParameters : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
// ConfigureCrystalReports();
}
protected void Page_Load(object sender, EventArgs e)
{
Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete);
CrystalReportViewer1.DisplayGroupTree = false;
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("~/Reports/CustOrderHistory.rpt"));
// When we build a report with a stored procedure that furnishes data
// from many tables, we need to login to all the underlying tables
// to avoid a dialog box asking the user for connection information.
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in rpt.Database.Tables)
{
TableLogOnInfo crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = connectionInfo;
crTableLogOnInfo.TableName = crTable.Name;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTableLogOnInfo = null;
}
CrystalReportViewer1.ReportSource = rpt;
}
private void ConfigureCrystalReports()
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "SQLServer2005";
connectionInfo.DatabaseName = "Northwind";
connectionInfo.UserID = "sa";
connectionInfo.Password = "ispl123";
SetDBLogonForReport(connectionInfo);
}
protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (Page.IsPostBack == false)
{
e.Command.Parameters["@CustomerID"].Value = DBNull.Value;
}
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
}
protected void SqlDataSource2_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
}
protected void CrystalReportSource1_Init(object sender, EventArgs e)
{
}
protected void CrystalReportSource1_Load(object sender, EventArgs e)
{
}
protected void CrystalReportSource1_PreRender(object sender, EventArgs e)
{
}
protected void CrystalReportSource1_DataBinding(object sender, EventArgs e)
{
}
protected void CrystalReportSource1_Unload(object sender, EventArgs e)
{
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Viswanath Majeti works as a Project Lead in .NET Technologies for a software development company in Hyderabad, India