Urgent pls: Crysta Report Login Failure

G

Guest

Hi,

It looks like posting a question on Sunday was not a good Idea that why I'm
trying it Today.
I'm using this code to run a crystal report and export it to pdf, and when
running it it in debug mode it working fine, but from the browser it's fails
to run telling me that the Crystal report failed to Login!!?

private void SetDBLogonForReport(ConnectionInfo connectionInfo,
ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}
private void SetDBLogonForSubreports(ConnectionInfo connectionInfo,
ReportDocument reportDocument)
{
Sections sections = reportDocument.ReportDefinition.Sections;
foreach (Section section in sections)
{
ReportObjects reportObjects = section.ReportObjects;
foreach (ReportObject reportObject in reportObjects)
{
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject subreportObject =
(SubreportObject)reportObject;
ReportDocument subReportDocument =
subreportObject.OpenSubreport(subreportObject.SubreportName);
SetDBLogonForReport(connectionInfo, subReportDocument);
}
}
}
}
private void GenerateInspectionReport()
{
ReportDocument O_Report = new ReportDocument();
string strReportPath = Request.PhysicalApplicationPath +
"\\InspectionReport.rpt";
string strPDF_Path = MyPath + "\\";
O_Report.Load(strReportPath);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "civicview";
connectionInfo.DatabaseName = "civicview";
connectionInfo.UserID = "_SYSTEM";
connectionInfo.Password = "SYS";
SetDBLogonForReport(connectionInfo, O_Report);
SetDBLogonForSubreports(connectionInfo, O_Report);
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new
ParameterDiscreteValue();
parameterDiscreteValue.Value = "275";
currentParameterValues.Add(parameterDiscreteValue);
ParameterFieldDefinitions parameterFieldDefinitions =
O_Report.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition =
parameterFieldDefinitions["EvaluationID"];
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
O_Report.ExportToDisk(ExportFormatType.PortableDocFormat,
strPDF_Path + "InspectionReport.pdf");
O_Report.Close();
O_Report.Dispose();

}


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top