Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to create new parameterField and value for both parameters. Your current code adds parameter, modifies it (change name and value) and adds same object again. This should be correct:</p> <pre><code> { ReportDocument reportDocument = new ReportDocument(); ParameterFields paramFields = new ParameterFields(); // ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); ParameterField paramField = new ParameterField(); ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); paramField.Name = "@Dept"; paramDiscreteValue.Value = TextBox1.Text.ToString(); paramField.CurrentValues.Add(paramDiscreteValue); paramFields.Add(paramField); paramField = new ParameterField(); // &lt;-- This line is added paramDiscreteValue = new ParameterDiscreteValue(); // &lt;-- This line is added paramField.Name = "@Name"; paramDiscreteValue.Value = TextBox2.Text.ToString(); paramField.CurrentValues.Add(paramDiscreteValue); paramFields.Add(paramField); CrystalReportViewer1.ParameterFieldInfo = paramFields; reportDocument.Load(Server.MapPath("CrystalReport.rpt")); CrystalReportViewer1.ReportSource = reportDocument; reportDocument.SetDatabaseLogon("sa", "sa", "OPWFMS-7KYGZ7SB", "test"); </code></pre> <p>}</p> <p><strong>EDIT:</strong> Error mentioned in comment is probably because there are two definitions of variable paramField or paramDiscreteValue in code. In one c# method you can't define variable with same name more than one time. Try code above as it is written and if you are still getting compiler error, please paste here full error text.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload