cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Parameters CR 2008 VS 2008 ASP.net

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member183750
Active Contributor

Answers (4)

Answers (4)

Former Member
0 Kudos

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);

}

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

SP 0 can be downloaded from here:

[ftp://ftp.businessobjects.com/pub/incoming/CR2008SP0.zip]

Hope this helps!!

Regards,

Shweta

Former Member
0 Kudos

I reinstalled it again with the link and I still have version 12.0.0.683

Former Member
0 Kudos

Never mind - the assemblies are the correct version 12.0.2000.0

Former Member
0 Kudos

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.

Former Member
0 Kudos

It is web and the report without parameters comes up fine in the browser, however with a report that has parameters it fails. This is on a developer PC so the inetpub\wwwroot folder does not have anything except the aspnet folder. I'm running it from debug so it uses the asp.net server

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

I'm running 12.0.0.683

Former Member
0 Kudos

Buddy,

Please apply SP0 your dll should have 12.0.2000.0 version.

That should help!

Regards,

AG.

Former Member
0 Kudos

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;

Former Member
0 Kudos

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.

Former Member
0 Kudos

I turned off prompt for parameter and the report works in crystal reports 2008 and prompts for the param - if i enable prompt for param it does prompt.

I'm using vs 2008 sp1