Adding a parameter to an ASP.NET deployed report causes a LoginException

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?
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top