I have a simple Crystal Report with a single parameter, which should produce a single item on the report. I have listed the code below, as well as the Parameter settings in the report. When I try to print the report to the printer (The final line in the code snippet), I receive the following Exception;
CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException was unhandled Message=Missing parameter values.
I have also tried the report using the ParameterFieldDefinitions and ParameterFieldDefinition objects, but I end up with the same results.
Any help would be greatly appreciated.
ReportDocument loReport = new ReportDocument();
loReport.Load(path+"InventoryItemsBarCodeLabel.rpt");
SqlConnectionStringBuilder loConnectionString = new SqlConnectionStringBuilder(ConnectionUtilities.getConnectionString());
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = Convert.ToInt32(psMasterId);
loReport.SetParameterValue("pnMasterId", parameterDiscreteValue.Value);
loReport.SetDatabaseLogon(loConnectionString.UserID,
loConnectionString.Password,
loConnectionString.DataSource,
loConnectionString.InitialCatalog);
loReport.Refresh();
loReport.PrintToPrinter(1, false, 1, 1);
Report Parameter: Name: pmMasterId, Type: Number, List of Values: Dynamic, Value = MasterId, Description = MasterId, Parameters = ?pnMasterId
Report Selection Record: {Inventory_Items.MasterId} = {?pnMasterId}
try to move SetDatabaseLogon() method before setting parameters; I believe it resets report document and any params previously passed.