on 06-29-2015 3:33 PM
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?
Do you mean to set the data source before I set the parameter value?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Ugh! My mistake! This was running a different report. Thanks for the help, Ludek!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Thank you, Ludek and Bhushan. The sequence of the settings was apparently causing the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That ran with no prompting, but no error. I do have the data saved with the report so it probably ran it with that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for responding, Ludek. Strangely, when I removed the setparametervalue, it gave the same error. I was not prompted for the values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.