ok this is my code snippet, just to elaborate my problem above, which is the Operation Illegal on Linked Parameter. I use this logic in order to load my report faster:
================================================== ====
DataTable dtQuery = new DataTable();
ReportDocument rdt = new ReportDocument();
rdt.Load(@"C:\Reports\Items.rpt");
string sql = "SELECT order_no, supplier_no, item_no, qty FROM Items WHERE order_no IN IN ('" + ord_no + "') "; //ord_no is a string, contains the order numbers to be printed, example is ord_no = (''1234', '3432', '2346');
dtQuery = Database.GetDataTable("Server1", sql); //GetDataTable is a function under Database class, Server1 sample name only
rdt.SetDataSource(dtQuery);
rdt.SetParameterValue("OrderNo", arr); //arr is an array, so it's possible to have many OrderNo to be printed in the report; this is the Main report's parameter
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
DataDefinition DataDef = rdt.DataDefinition;
ParameterFieldDefinitions pm = DataDef.ParameterFields;
ParameterFieldDefinition Param1; //Param1 & Param2 are my subreport parameters
ParameterFieldDefinition Param2;
for (int i = 0; i < dtQuery.Rows.Count; i++)
{
Param1 = pm["Pm-supplier_no", "Supplier"]; //Supplier is a subreport
paramDiscreteValue.Value = dtQuery.Rows[i]["supplier_no"].ToString();
Param1.CurrentValues.Add(paramDiscreteValue);
Param1.ApplyCurrentValues(Param1.CurrentValues);
Param2 = pm["Pm-item_no", "ItemDesc"]; //ItemDesc is another subreport which takes item_no as the parameter
paramDiscreteValue.Value = dtQuery.Rows[i]["item_no"].ToString();
Param2.CurrentValues.Add(paramDiscreteValue);
Param2.ApplyCurrentValues(Param2.CurrentValues);
}
================================================== ====
Notes:
- In my Supplier subreport, I have a parameter called Pm-supplier_no. This is the link to the MAIN report's supplier_no field. This subreport will display all the supplier details. In this subreport's Record Selection, I have SupplierTable.supplier_no = {?Pm-supplier_no}
- In my ItemDesc subreport, I have also a parameter called Pm-item_no. This is another link to the MAIN report's item_no. This subrepot will display all the item details. The reason why I have a for loop is that it's possible to have many items in the main report, so I have to pass also the exact number of items to its subreport. In this subreport's Record Selection, I have ItemTable.item_no = {?Pm-item_no}.
Thanks a lot! Any help will be appreciated!