Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Passing Parameter To Report Post Reply Post New Topic
Page  of 2 Next >>
Author Message
mdbriggs
Newbie
Newbie
Avatar

Joined: 23 Nov 2008
Online Status: Offline
Posts: 16
Quote mdbriggs Replybullet Topic: Passing Parameter To Report
    Posted: 30 Nov 2011 at 2:29am
How do I pass a parameter to a report programmatically without having the dialog box to enter a parameter display just before the report displays?
 
Marlon
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 30 Nov 2011 at 9:03am
from an application, you would instantiate the report, then it something like:
reportObject.parameters("reportParameterName", value)
 
then you would display the report.
 
if it is not exactly this, it is fairly close.
IP IP Logged
mdbriggs
Newbie
Newbie
Avatar

Joined: 23 Nov 2008
Online Status: Offline
Posts: 16
Quote mdbriggs Replybullet Posted: 01 Dec 2011 at 4:26am
Thanks for responding.
 
I was able to figure out how to set a parameter(s) for the report.
 
The problem I'm having now is that I'm having intermitent issues with preventing the dialog box from displaying, which asks the user to input the parameter value.
 
In addition, I have several parameters for which I must set the values for programmatically. Like the aforementioned issue of intermitentancy, occassionaly one or two of the parameter values that were set in code will not display on the report.
 
For one of the parameters if I remove it from the report, then put it back on the report, run the application, then display the report, the set parameter value displays.
 
For the other parameter in question, it will not display at all if I try to pass a numeric value to it. And yes, I created the parameter as Number type. The only time this particular parameter seems to work is when I create it a string and "handjam" a string value to be passed to it via code. Even in that situation it display intermitently.
 
I don't know what's causing this but it's very frustrating to say the least. This is an application which is using WPF, VS2010, C#, and the most recent downloaded version of Crystal Reports for VS2010 from SAP.
 
The code fragment for how I set the parameter values and kept the "Enter parameter value" dialog box from displaying is as follows:
 
ReportClass AR = new ReportClass();
AR.SetDataSource(ConvertCollection.ConvertToDataTable(saColl));
crViewer.ViewerCore.ReportSource = AR;
AR.SetParameterValue("ProcessorDetails", SystemInfo.GetFunction1());
AR.SetParameterValue("ProcessorType", SystemInfo.GetFunction2());
AR.SetParameterValue("AvailDrives", SystemInfo.GetFunction3());
AR.SetParameterValue("Browser", SystemInfo.GetFunction4());
AR.SetParameterValue("Username", "John Doe");
AR.SetParameterValue("SystemMemory", SystemInfo.GetFunction5());
 
When I put the code to set the parameter values BEFORE setting the ReportSource the "Enter parameter value" dialog box would display all the time.
 
When I put the code to set parameter values AFTER setting the ReportSource the "Enter parameter value" dialog box would display intermitently.
 
The last two parameters are the one's I'm having an issue with in terms of the value displaying intermitently.
 
Any assistance that can help me solve this mystery would be much appreciated.
 
Marlon
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 Dec 2011 at 5:52am
alas, I have a rough idea how to do this, but I don't actually create any reports this way (that is the older way).  Our application gathers the data first and 'pushes' it to the report, so we don't have set the parameters to 'pull' the data.
 
checking our code, the only big difference that I see is that we create an instance of the report, and you using ReportClass, which may or maynot be some cause.
 
the only other thing that comes to mind is if the report is using Command Objects that use the parameters, than can cause the parameter to be prompted for again (other have reported this issue)
 
HTH
IP IP Logged
mdbriggs
Newbie
Newbie
Avatar

Joined: 23 Nov 2008
Online Status: Offline
Posts: 16
Quote mdbriggs Replybullet Posted: 01 Dec 2011 at 6:56am
I'm not using any command objects to pull the data to the report, consequently they're not using the parameters in the report. The way I'm getting data on the report is by pushing data to it via an object collection.
 
The ReportClass reference was just a generic way of describing how I'm instantiating a report object from the report class that's generated as a result of creating and embedded report.
 
Same is true for the SystemInfo.GenericFucntion1, et al. references. GenericFunction1 is just a generic reference to the method that's retrieving the data in a SystemInfo class within the project.
 
Marlon
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 Dec 2011 at 10:56am
ok.
 
then I don't know why they are showing as they haven't in our app to the best of my knowledge.
 
 
IP IP Logged
mdbriggs
Newbie
Newbie
Avatar

Joined: 23 Nov 2008
Online Status: Offline
Posts: 16
Quote mdbriggs Replybullet Posted: 01 Dec 2011 at 11:46am
Can you provide a sample of what you're doing in your code. Maybe there's something I can glean from it that I'm apparently not doing correctly.
 
Marlon
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 02 Dec 2011 at 3:31am

Dim frmReportViewer As New ReportViewer

Dim rptRc As New AgrisoftReports.Reports.rpt_Railcar

rptRc.SetParameterValue(

"@pReportDate", m_dateReport)

SetReportDBConnection(rptRc)

frmReportViewer.CrystalReportViewer1.ReportSource = rptRcfrmReportViewer.MdiParent =

Me.MdiParent

frmReportViewer.Show()
 
here' what we're doing, sorry about the formatting
 
IP IP Logged
mdbriggs
Newbie
Newbie
Avatar

Joined: 23 Nov 2008
Online Status: Offline
Posts: 16
Quote mdbriggs Replybullet Posted: 02 Dec 2011 at 5:59am
You're right.... I don't see a lot of difference between what you're doing and what I'm doing other than you're using an @ sign in front of your parameter name. I'm assuming it's because you're using a stored procedure or something?
 
I've been trying to debug one issue at a time that I'm having with this report. My biggest frustration right now is that the "Enter Parameter Value" dialog box keep displaying intermitently.
 
I can see in the debugger that data is being passed to the parameters. However, when the report displays the dialog box appears, occassionally, and consequently the parameter values that I sent programmatically are not being sent to the report.
 
Any thoughts on what I can do to prevent this "thorn in my side" from appearing?
 
Anyone else that has read this post I would certainly appreciate any input you could provide also?
 
Marlon
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 02 Dec 2011 at 6:48am
Since I am actually not that familiar with these reports...they are part of the 'legacy' and will be replaced at some point in the future.  Your right, they are usually driven by stored procs as you can just do so much more in a proc.
 
Again, our codes just works, so I don't have any ideas as to why the parameter box appears...it's the intermittent part that is annoying.
 
Sorry can't be of more help
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.