DotNet Academy of Rajesh Rolen

Solutions by Rajesh Rolen

Crystal Report in asp.net

To create crystal report in asp.net follow below steps
1. take a crystal report viewer on page (i have given name "crv" to it)
then write below code in code behind file.

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

private void showreport()
{
ReportDocument report = new ReportDocument();
report.Load(Server.MapPath("MyReportName.rpt"));
report.SetDataSource(objrep.ReportDataSource);
SetTableLocation(report.Database.Tables);
crv.ReportSource = report; //crv is your Crystal report viewer's name.
}


private void SetTableLocation(Tables tables)
{
ConnectionInfo connectionInfo = new ConnectionInfo();

connectionInfo.ServerName = @"DBSERVER2\SQL2005";
connectionInfo.DatabaseName = "dbMEAVer5web";
connectionInfo.UserID = "sa";
connectionInfo.Password = "admin55";

foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
}



Solution by: Rajesh Rolen

0 comments:

Post a Comment

About this blog

My Blog List

Advertise On This Site

Site Info

Advertise on this Site

To advertise on this site please mail on RajeshRolen@gmail.com

Information Source

About

Pages

Dot Net Academy

Advertis in This Area of Site

Powered by Blogger.

Followers

Search This Blog