views:

301

answers:

2

Well I have a Cyrstal report which has 4 sub reports on and it is linked through an ItemID column and a Culture, so it has a parameter value "?Pm-ItemID" and "?Pm-Culture" now i'm using DataSet to load the data to the Crystal Report's datasource, when I run the report its giving me an error which was an asking parameter field was not suplied, so i think my question would be what am I going to pass to those ParameterFields?

here's an idea.

ReportDocument myreport = new ReportDocument();
myreport.Load("C:\MyReport.rpt");
DataSet ds = GenerateReportData();
myreport.SetDataSource(ds);

//Loop through each to Load the DataSet
for (int i = 0; i < myreport.Subreports.Count; i++)
{
    ReportDocument subreport = myreport.SubReports[i];
    DataSet subds = GenerateReportData(subreport.name)
    subreport.SetDataSource(subds);
}

//I can see that there's a parameterfields in myreport.ParameterFields
//As I look through inside it there are 8 ParameterFields repeating Pm-ItemID and Pm-Culture
foreach (ParameterField pf in myreport.ParameterFields)
{
    myreport.SetParameterValue(pf.Name, Value???);
}
A: 

I don't know about Crystal, but in SSRS it works like this:

1) create a subreport and create some parameters

2) create the main report, put there the subreport and in the properties you can specify what to bind to the subreport's parameters

Conclusion: I don't think this is supposed to be set in code, rather report designer.

kubal5003
it is set in the report designer, it is linked MainItemReport.ItemID linked to SubItemReport.ItemID and so on, but as the report run it's asking for the value of ?Pm-ItemID and ?Pm-Culture
Juvil John Soriano
as you can see, I thought setting the data set through each subreports was sufficient, notice the foor loop, but as it goes along, i got an error that some parameter fields where it has no value.
Juvil John Soriano
A: 

Well, I see what's wrong.

ReportDocument subreport = myreport.SubReports[i];
DataSet subds = GenerateReportData(subreport.name)
subreport.SetDataSource(subds);

should not be done this way, it should be

DataSet subds = GenerateReportData(subreport.name)
myreport.SubReports[i].SetDataSource(subds);
Juvil John Soriano
I forgot this is a com object, which might not support oop.
Juvil John Soriano