kurtzky 0 Newbie Poster

Hello. Good day. I have this problem with my current program right now. I have a separate report created in Seagate Crystal Reports, and I'm integrating it to my program in C#.

I'm using CrystalDecisions and calls the ReportDocument class.

Under that report, I have many subreports. What I want to do is to select ALL the fields in the MAIN report and put it in the DataTable, then I would put that DataTable as the DataSource of my ReportDocument.The problem is, when I set a value to any of my subreport parameters, I am getting an error "Operation Illegal on Linked Parameters"..

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 + "') "; //[I]ord_no is a string, contains the order numbers to be printed, example is ord_no = ('1234', '3432', '2346');[/I]
dtQuery = Database.GetDataTable("Server1", sql); //[I]GetDataTable is a function under Database class, Server1 sample name only[/I]
rdt.SetDataSource(dtQuery); 
rdt.SetParameterValue("OrderNo", arr); //[I]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[/I]

ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
DataDefinition DataDef = rdt.DataDefinition;
ParameterFieldDefinitions pm = DataDef.ParameterFields;
ParameterFieldDefinition Param1; //[I]Param1 & Param2 are my subreport parameters[/I]
ParameterFieldDefinition Param2;
for (int i = 0; i < dtQuery.Rows.Count; i++)
{
Param1 = pm["Pm-supplier_no", "Supplier"]; //[I]Supplier is a subreport[/I]
paramDiscreteValue.Value = dtQuery.Rows[i]["supplier_no"].ToString();
Param1.CurrentValues.Add(paramDiscreteValue);
Param1.ApplyCurrentValues(Param1.CurrentValues);

Param2 = pm["Pm-item_no", "ItemDesc"]; //[I]ItemDesc is another subreport which takes item_no as the parameter[/I]
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 field. 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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.