B
Bill Sempf
Hi, everyone! Long time no see!
I have a report developed in Crystal 9 that I have implemented in
ASP.NET. I am not using the Viewer, I am passing it to the screen as
a PDF.
Becasue the report directly connects to a database to collect it's
information, I have had to use the infamous security loop to get
information to each table in the system.
//crConnectionInfo.ServerName = @"<myserver>";
crConnectionInfo.ServerName = "OCSA";
crConnectionInfo.DatabaseName = "OCSA";
crConnectionInfo.UserID = "<myusername>";
crConnectionInfo.Password = "<mypassword>";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
//Do the stupid security dance
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in
crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
//Do the more stupid subreport dance.
Sections crSections;
ReportObjects crReportObjects;
SubreportObject crSubreportObject;
crSections = crReportDocument.ReportDefinition.Sections;
ReportDocument subRepDoc = new ReportDocument();
foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
foreach (ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
crSubreportObject = (SubreportObject)crReportObject;
subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
crDatabase = subRepDoc.Database;
crTables = crDatabase.Tables;
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable
in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
}
}
}
This solved the first login exception no problem, and was a fairly
easy fix.
So, I have some reports that work. Then I got a report with a
parameter. No problem, I added this code:
//Pass in the parameter
ParameterValues parameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new
ParameterDiscreteValue();
string classText = orgRosterClassDDL.SelectedItem.Text.ToString().Substring(4,orgRosterClassDDL.SelectedItem.Text.ToString().Length-4);
parameterDiscreteValue.Value = classText;
ParameterFieldDefinitions parameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition =
parameterFieldDefinitions["Class"];
parameterValues = parameterFieldDefinition.CurrentValues;
parameterValues.Add(parameterDiscreteValue);
parameterFieldDefinition.ApplyCurrentValues(parameterValues);
And went about my way. BUT, this code, when added, causes another
login exception at the point of Export.
My question - the question that even Crystal Decisions Tech Support
can't solve - is
WHY?
I have a report developed in Crystal 9 that I have implemented in
ASP.NET. I am not using the Viewer, I am passing it to the screen as
a PDF.
Becasue the report directly connects to a database to collect it's
information, I have had to use the infamous security loop to get
information to each table in the system.
//crConnectionInfo.ServerName = @"<myserver>";
crConnectionInfo.ServerName = "OCSA";
crConnectionInfo.DatabaseName = "OCSA";
crConnectionInfo.UserID = "<myusername>";
crConnectionInfo.Password = "<mypassword>";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
//Do the stupid security dance
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in
crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
//Do the more stupid subreport dance.
Sections crSections;
ReportObjects crReportObjects;
SubreportObject crSubreportObject;
crSections = crReportDocument.ReportDefinition.Sections;
ReportDocument subRepDoc = new ReportDocument();
foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
foreach (ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
crSubreportObject = (SubreportObject)crReportObject;
subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
crDatabase = subRepDoc.Database;
crTables = crDatabase.Tables;
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable
in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
}
}
}
This solved the first login exception no problem, and was a fairly
easy fix.
So, I have some reports that work. Then I got a report with a
parameter. No problem, I added this code:
//Pass in the parameter
ParameterValues parameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new
ParameterDiscreteValue();
string classText = orgRosterClassDDL.SelectedItem.Text.ToString().Substring(4,orgRosterClassDDL.SelectedItem.Text.ToString().Length-4);
parameterDiscreteValue.Value = classText;
ParameterFieldDefinitions parameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition =
parameterFieldDefinitions["Class"];
parameterValues = parameterFieldDefinition.CurrentValues;
parameterValues.Add(parameterDiscreteValue);
parameterFieldDefinition.ApplyCurrentValues(parameterValues);
And went about my way. BUT, this code, when added, causes another
login exception at the point of Export.
My question - the question that even Crystal Decisions Tech Support
can't solve - is
WHY?