cancel
Showing results for 
Search instead for 
Did you mean: 

Missing parameter values error from C# application

anitahartman
Explorer
0 Kudos

I am getting a missing parameter values when I attempt to set the parameter values from my C# application.  There is a date parameter in the main report and there is a subreport with three parameters but they are all linked to the main report.

Here is my code:

reportDoc.Load("LEECRP.rpt");

reportDoc.SetParameterValue("WEDate", dateTimePicker1.Value.Date);

reportDoc.Database.Tables[0].SetDataSource(bidMDataSet);

reportDoc.Database.Tables[1].SetDataSource(payrollDataSet);

reportDoc.RecordSelectionFormula="{CostWork.Job}='" + job + "'";

reportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\\Costing");

What am I missing?

Accepted Solutions (1)

Accepted Solutions (1)

anitahartman
Explorer
0 Kudos

Do you mean to set the data source before I set the parameter value?

former_member183750
Active Contributor
0 Kudos

Yes.

former_member188030
Active Contributor
0 Kudos

Try this.

reportDoc.Load("LEECRP.rpt");

reportDoc.Database.Tables[0].SetDataSource(bidMDataSet);

reportDoc.Database.Tables[1].SetDataSource(payrollDataSet);

reportDoc.SetParameterValue("WEDate", dateTimePicker1.Value.Date);

reportDoc.RecordSelectionFormula="{CostWork.Job}='" + job + "'";

reportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\\Costing");

Thanks,

Bhushan

Answers (8)

Answers (8)

anitahartman
Explorer
0 Kudos

Ugh!  My mistake!  This was running a different report.  Thanks for the help, Ludek!

anitahartman
Explorer
0 Kudos

I no longer get an error, but, on closer examination, I realize that the subreport is no longer running.  Any idea why?  It does run fine from within the designer.

former_member183750
Active Contributor
0 Kudos

Depends on a few things.

Is it a subreport on demand?

What section it is in.

What database connection does it use.

Etc., etc.

See if placing the special field N of M on the report helps. This forces the report to run from page 1 to M (last page). Without this, the report only brings in enough data to format the 1st page, then second page when you go to page two, etc.

And apologies for my short answer there - I had like 10 seconds to reply to catch my train

- Ludek

Message was edited by: Ludek Uher

anitahartman
Explorer
0 Kudos

Thank you, Ludek and Bhushan.  The sequence of the settings was apparently causing the problem.

anitahartman
Explorer
0 Kudos

Okay, I took off the save data.  It gave the error about the missing parameter again so I added back the code to set the parameter and it worked.  Then I tried to add back the code to set the data source and now I am getting the error about the missing parameter again.  I need to set the datasource, though, because I am building a work file for each job and then run the report.  What can I try now?

former_member183750
Active Contributor
0 Kudos

Ok good. Place your parameter code after you do the logon code.

- Ludek

anitahartman
Explorer
0 Kudos

That ran with no prompting, but no error.  I do have the data saved with the report so it probably ran it with that.

former_member183750
Active Contributor
0 Kudos

Yeah... take the saved data off please.

- Ludek

anitahartman
Explorer
0 Kudos

Thanks for responding, Ludek.  Strangely, when I removed the setparametervalue, it gave the same error.  I was not prompted for the values.

former_member183750
Active Contributor
0 Kudos

Interesting...

What about just this code:

reportDoc.Load("LEECRP.rpt");

reportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\\Costing");

That should prompt for db logon as well as the parameter - essentially duplicating the same steps you do in the designer.

- Ludek

former_member183750
Active Contributor
0 Kudos

Hi Anita

Best way to test this is to initially not set the param in code. Let the report prompt, fill in the value and see if the report comes up. If it does, the next step is to code the param. For dates see the sample app csharp_win_sub_daterange_param_engine.zip

Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki

Also, see KBA - 1214110 - How to pass a Date/Time parameter to a report at runtime using VB .NET

For more info, enter the search string 'crystal net parameter date' in the search box - top right corner. You will get a number of KBAs, blogs, etc.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

anitahartman
Explorer
0 Kudos

By the way, it runs fine from within the Crystal Reports designer and when I run it from there I am prompted for only the date parameter.