|
i take one data set using ado.net(sql server 2000),
i take one crystal reporti,that is name is crystalreportTest,
its file path is c:\Test\CrystalReportTest.rpt,my web application in c:\Test,
my dataset name is DataSetTest,i use this dataset in my crystal Report,i take crystalviewer1 &set the report source which is CrystalReportTest.rpt,
following code are used for solve the login problem(in crystalviewer property i remove logon prompt properties)my code is as follows-----
using CrystalDecisions.CrystalReports.Engine.Migration ;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared.Interop;
using System.Data.SqlClient;
using CrystalDecisions.Web;
using CrystalDecisions.Enterprise;
using CrystalDecisions.ReportAppServer;
using CrystalDecisions.Reporting.WebControls;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Web.Services;
public partial class _Default : System.Web.UI.Page
{
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
CrystalDecisions.CrystalReports.Engine.Table crTable;
CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
crConnectionInfo.ServerName = "SERVER";
crConnectionInfo.DatabaseName = "RESERVATION";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "sa";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
crReportDocument.Load(@"C:\Test\CrystalReportTest.rpt");
for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables [i];
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo =crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location = "RESERVATION.dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);
}
CrystalReportViewer1.ReportSource = crReportDocument ;
}
}
i use ReportDocument because in my application crystal report object is not set,
when run my code it shows Invalid report file path.i don't know what is happinning ,
i have done lot of research on it but i don't findthe right solution,
i don't know what is my mistak,when i run this code ,plz help me anybody
thank you very much for your support
asp.net using c#
|
|
|
|