on 09-05-2008 3:42 PM
Hi All,
I need to pass 5 Parameters to a report and I've tried just about every example on the net a side from my own versions of what I think it should do and no luck. If anyone can help me I would greatly apprieciate it.
thanks
rich
Hi Richard,
Please let us know if SP0 is applied and the code that you are using.
Also before proceeding ahead with the code you need to make sure that the report runs fine in designer.
Below mentioned code works for me. Like to try?
// Name spaces added
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
ReportDocument rdoc = new ReportDocument();
rdoc.Load("c:\\windows\\Report.rpt");
rdoc.SetParameterValues("MyparamtereName","Value");
CrystalReportViewer1.ReportSource = rdoc;
Hope that helps!
AG.
Edited by: AG on Sep 5, 2008 8:46 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SP0 can be downloaded from here:
https://smpdl.sap-ag.de/~sapidp/012002523100007528552008E/cr2008_sp0.zip
Ludek
I know this is a long time after the last post, but I've been looking everywhere for a solution. Finally, after a lot of trial and error I got a solution to "Passing Parameters CR 2008 VS 2008 ASP.net"
Hope this can help someone.
The report needs 2 parameters: @MainCnt and @PrdCnt declared in a stored procedure
First update CR to the newest SP. Currently SP2. Place a CrystalReportViewer and CrystalReportsource component on the aspx web form.
Add references:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
Then, the code to display the report:
protected void btnShow_Click(object sender, EventArgs e)
{
ReportDocument crRpt = new ReportDocument();
crRpt.Load(Server.MapPath("internRecievedPerContract.rpt")); //CR designed in VS2008
crRpt.SetDatabaseLogon("Username", "Passord", "ServerName", "DatabaseName"); //logon data for your server
crRpt.SetParameterValue("@MainCnt", txtMainCnt.Text);
crRpt.SetParameterValue("@PrdCnt", txtPrdCnt.Text); //Textboxes on aspx page for user input
CrystalReportViewer1.ReportSource = crRpt;
}
and if you need to print the report from code, not using the print button on the toolbar:
protected void btnPrint_Click(object sender, EventArgs e)
{
ReportDocument crRpt = new ReportDocument();
crRpt.Load(Server.MapPath("internRecievedPerContract.rpt")); //CR designed in VS2008
crRpt.SetDatabaseLogon("Username", "Passord", "ServerName", "DatabaseName"); //logon data for your server
crRpt.SetParameterValue("@MainCnt", txtMainCnt.Text);
crRpt.SetParameterValue("@PrdCnt", txtPrdCnt.Text); //Textboxes on aspx page for user input
crRpt.PrintToPrinter(1, false, 0, 0);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Johann, thank you for posting your solution.
Parameters is certainly a Pandora's box. I'm working on an article that would explain and de-mystify parameters, but at this time, it's a slow go given all else going on. One day...
For now, below is a number of links re. parameters from these forums that may prove to be of help:
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6812660
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6628788
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6844917
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6756082
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6747359
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6797152
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6699653
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6852866
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6683506
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6912888
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6661653
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6435353
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6439091
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6623914
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6623870
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6517050
https://forums.sdn.sap.com/click.jspa?searchID=21443653&messageID=6699412
https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
SP 0 can be downloaded from here:
[ftp://ftp.businessobjects.com/pub/incoming/CR2008SP0.zip]
Hope this helps!!
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let us know if there are any specific error that you are getting. Do the reports without parameter work fine? Is this a web or windows based application? In case of a web-based application can you make sure that you have got CrystalReportViewersXX folder is available in the iis under the application's virtual folder?
Thanks.
AG.
Richard, I'd like you to see if you can set the parameters using one of our sample applications. [This|https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe] self extracting exe contains a number of samples. I'd like you to have a look at vbnet_win_paramengine sample to see how the app handles parameters. See if you can modify the app to use your report and your parameters. If your reports needs a database logon, you may want to see vbnet_win_dbengine for the code.
Ludek
I'm running 12.0.0.683
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
no matter what I do I get missing parameter field and I even took the next step in creating a report with only one parameter and it still fails. see the code below.
ReportDocument crReport = new ReportDocument();
crReport.Load("c:\project\test.rpt");
crReport.SetParameterValue(1, "dfsdf");
CrystalReportViewer1.ReportSource = crReport;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I take it that the report runs fine from designer and prompts for parameter whenever you refresh the report (?).
If you comment out the SetParametereValues method line does the report prompts for parameter, while calling it from the application?
By the way, what edition of VS are you using?
AG.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.