I have a crystal report that works fine when run through Crystal, which
I am triying to incorporate into a crystal report viewer. The report
takes 1 parameter, which is either 0 or 1. If the paremeter is 1 then a
filter is placed onto the data by the database server (Oracle PL/SQL
procedure in a package), parameter is 0 then it doesn't use the filter.
When I run this with the filter on the program works fine and the
report is displayed, but when I run it with the parameter of 0 it fails
with a query engine error. I originally used crystal 9 to write the
report, and then incorporated it into C# by adding it to the project
and doing a verify database, followed by a save. Below is the code that
I am using for the report, although I'm not sure how it could be wrong
since it works for one parameter??
private void ShowReport(String reportName , Int32 numParam)
{
CrystalDecisions.CrystalReports.Engine.ReportDocum ent reportDoc =
new CrystalDecisions.CrystalReports.Engine.ReportDocum ent() ;
CrystalDecisions.Shared.ParameterValues pv = new
CrystalDecisions.Shared.ParameterValues() ;
CrystalDecisions.Shared.ParameterDiscreteValue pdv = new
CrystalDecisions.Shared.ParameterDiscreteValue() ;
reportDoc.Load (reportName);
CrystalDecisions.CrystalReports.Engine.Table tblCurrent;
CrystalDecisions.Shared.TableLogOnInfo tliCurrent ;
for (int i = 0; i < reportDoc.Database.Tables.Count ; i++)
{
tblCurrent = reportDoc.Database.Tables [i];
tliCurrent = tblCurrent.LogOnInfo ;
tliCurrent.ConnectionInfo.ServerName = "cfsprod";
tliCurrent.ConnectionInfo.UserID = "infolease";
tliCurrent.ConnectionInfo.Password = "infolease";
}
//pdv.Value = numParam;
pdv.Value = 0;
pv.Add (pdv);
reportDoc.DataDefinition.ParameterFields[0].ApplyCurrentValues (pv);
crViewer.ReportSource = reportDoc;
crViewer.Update ();
}