Crystal report login Failure

G

Guest

Hi,

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top