Home > Archive > Visual Basic Crystal Reports > January 2006 > Crystal Report parameter dialog box
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Crystal Report parameter dialog box
|
|
| Mounilk 2006-01-15, 7:16 pm |
| I have a CrystalReportViewer(crv) on my form. I also have a dataset
(dtsReportData) populated with the required data and i have a
ReportDocument (rdReport) object. The data source for the crystal
report (CR 11) is a stored procedure.
This is what i am doing:-
rdReport.Load("ReportLocation"); //ReportLocation is the file path.
rdReport.SetDataSource(dtsReportData);
crv.ReportSource = rdReport;
When the Crystal Report Viewer loads up, it brings up a dialog box
asking to enter the various parameters. I do not have different forms
(to accept the report parameters from the user) for different reports.
I have only 1 form which is dynamically generated with the required
controls (labels/textboxes/datetimepickers etc ) depending on which
report the user selects in the application.
Can any one shed some light on why this is happening and how can i get
around it? If anyone has had a similar problem and has managed to
solved it, i would love to hear how you did it.
TIA,
Mounil.
| |
| Shariq 2006-01-16, 7:15 pm |
| This dialog box asking for several parameters iscomming up from the Crystal
Report. Your report has several parameter fields and you need to either enter
these parameter values when the dialog box comes up or pass these parameters
values in your code. Following is a VB.Net example code whaich adds a
parameter value for Crystal Report.
crParameterField = crParameterFields.Item("CustName")
crParameterValues = crParameterField.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = sCustName
crParameterValues.Add(crParameterDiscreteValue)
If you need more information on how to pass parameters in vb/vb.net then
post back and I will post code for you.
"Mounilk" wrote:
> I have a CrystalReportViewer(crv) on my form. I also have a dataset
> (dtsReportData) populated with the required data and i have a
> ReportDocument (rdReport) object. The data source for the crystal
> report (CR 11) is a stored procedure.
>
> This is what i am doing:-
>
> rdReport.Load("ReportLocation"); //ReportLocation is the file path.
> rdReport.SetDataSource(dtsReportData);
> crv.ReportSource = rdReport;
>
> When the Crystal Report Viewer loads up, it brings up a dialog box
> asking to enter the various parameters. I do not have different forms
> (to accept the report parameters from the user) for different reports.
> I have only 1 form which is dynamically generated with the required
> controls (labels/textboxes/datetimepickers etc ) depending on which
> report the user selects in the application.
>
> Can any one shed some light on why this is happening and how can i get
> around it? If anyone has had a similar problem and has managed to
> solved it, i would love to hear how you did it.
>
> TIA,
> Mounil.
>
>
| |
| Mounilk 2006-01-16, 7:15 pm |
| Hi Shariq,
Thanks a lot for your reply. developed my app in VS
2003 and it was all running very smoothly. I recently migrated it to
VS2005 and then I started getting this problem.
Although I dont think this is a VS 2005 issue; but something with CR
itself.
I'll try to explain my problem in detail.
I am using Crystal Reports XI; VS 2005; SQL Server 2000;
For all my reports, the reports' datasource is a Stored Procedure. And
in most cases than not, these are paramaterised SP's.
In my application, I have a listbox with a list of available reports.
The user then selects to view one report. This then loads up a
dynamically generated form with a tabpage for each of the parameters
that the Stored Procedure needs. The user then enters values for each
of the parameters. I then create a SQL statement( something like
....execute MyStoredProc value1 value2) where value1 etc are the values
the user entered for the parameters on the dynamyically generated form.
The resultant recordset is then stored into a DataSet object.
I then load the report into a ReportDocument object ie
rdReport.Load("ReportLocation"); assign the DataSet as the
ReportDocuments' Datasource ie rdReport.SetDataSource(dtsReportData);
and finally assign the ReportDocument to the CrystalReportViewer.
As i mentioned earlier, this was all working smoothly untill now...I am
getting the default CR "Enter Parameters" dialog and I havent got a
clue as to what has triggered this behaviour.
It is not possible for me to know how many parameters a stored
procedure for a report will contain and what those parameters will be
for reports designed in the future for the client, so I do not know how
I can implement something like what you suggested.
I am pretty new to the world of reporting so excuse my
explanation....if you need any further information to understand my
problem, please let me know. I will really appreciate any help that you
can provide.
Thanks,
Mounil.
| |
| Shariq 2006-01-19, 7:10 pm |
| Mounilk,
Either a parameter field has been added to your report or you code has been
modified to removed the value for the parameter fields.
From you previous comments; it seems that your are not passing any
parameters (e.g. crParameterField = crParameterFields.Item("CustName"))
Open up the report and check if you have any fields under [?]Parameter
Fields. Either remove this from the report or add it to your code.
"Mounilk" wrote:
> Hi Shariq,
> Thanks a lot for your reply. developed my app in VS
> 2003 and it was all running very smoothly. I recently migrated it to
> VS2005 and then I started getting this problem.
> Although I dont think this is a VS 2005 issue; but something with CR
> itself.
>
> I'll try to explain my problem in detail.
>
> I am using Crystal Reports XI; VS 2005; SQL Server 2000;
>
> For all my reports, the reports' datasource is a Stored Procedure. And
> in most cases than not, these are paramaterised SP's.
>
> In my application, I have a listbox with a list of available reports.
> The user then selects to view one report. This then loads up a
> dynamically generated form with a tabpage for each of the parameters
> that the Stored Procedure needs. The user then enters values for each
> of the parameters. I then create a SQL statement( something like
> ....execute MyStoredProc value1 value2) where value1 etc are the values
> the user entered for the parameters on the dynamyically generated form.
> The resultant recordset is then stored into a DataSet object.
>
> I then load the report into a ReportDocument object ie
> rdReport.Load("ReportLocation"); assign the DataSet as the
> ReportDocuments' Datasource ie rdReport.SetDataSource(dtsReportData);
> and finally assign the ReportDocument to the CrystalReportViewer.
>
> As i mentioned earlier, this was all working smoothly untill now...I am
> getting the default CR "Enter Parameters" dialog and I havent got a
> clue as to what has triggered this behaviour.
>
> It is not possible for me to know how many parameters a stored
> procedure for a report will contain and what those parameters will be
> for reports designed in the future for the client, so I do not know how
> I can implement something like what you suggested.
>
> I am pretty new to the world of reporting so excuse my
> explanation....if you need any further information to understand my
> problem, please let me know. I will really appreciate any help that you
> can provide.
>
> Thanks,
> Mounil.
>
>
| |
| Mounilk 2006-01-19, 7:10 pm |
| Hi Shariq,
Thanks for your reply,
As i mentioned earlier,
my reports's datasource is a sql stored procedure. The stored
procedure(SP) has a parameter. When designing a report, when i add the
SP as the datasource CR automatically assigns the parameter in SP as a
parameter under the [?]Parameter Fields. I tried to remove the
parameter from there, but i dont see any options to remove it. i.e when
i right-click on [?]Parameter Fields the options i get are New... and
Refresh. When i right click on the parameter itself under [?]Parameter
Fields, i get the options Insert to report, New, Edit, Rename and
Refresh. Am i missing something?
| |
| Shariq 2006-01-19, 7:10 pm |
| You need to pass the parameter value to CR; following is what you need to add
to your code:
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterValues As ParameterValues
CrViewer.ReportSource = "YourReportLocation"
crParameterFields = CrViewer.ParameterFieldInfo
crParameterField = crParameterFields.Item("YourCRParameterName")
crParameterValues = crParameterField.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = YourParameterValue
crParameterValues.Add(crParameterDiscreteValue)
CrViewer.ParameterFieldInfo = crParameterFields
CrViewer is the Crystal Report control on your form.
"Mounilk" wrote:
> Hi Shariq,
> Thanks for your reply,
> As i mentioned earlier,
> my reports's datasource is a sql stored procedure. The stored
> procedure(SP) has a parameter. When designing a report, when i add the
> SP as the datasource CR automatically assigns the parameter in SP as a
> parameter under the [?]Parameter Fields. I tried to remove the
> parameter from there, but i dont see any options to remove it. i.e when
> i right-click on [?]Parameter Fields the options i get are New... and
> Refresh. When i right click on the parameter itself under [?]Parameter
> Fields, i get the options Insert to report, New, Edit, Rename and
> Refresh. Am i missing something?
>
>
| |
| Bullfrog 2006-01-29, 7:02 pm |
| I'm having a similar but opposite problem. I can get my prompt box to come
up in CR9 when developing the report. However, when I go to view the report
in my ASP.NET (VB) Webform I have to programmatically define the parameter
values similar to the snippets provided. I don't want to write the code; I
just want the parameter box to pop up. I've tried saving w/ and w/o data in
the report and refreshing. It gives invalid parameter definition if I don't
define within in code.
Is the Parameter Prompt even available in the Webform (versus the Winform)?
Confused.
(sorry for duplicate post)
"Shariq" <Shariq@discussions.microsoft.com> wrote in message
news:3B7AF851-11DD-4926-A837-5F0E51B7056B@microsoft.com...[color=darkred]
> You need to pass the parameter value to CR; following is what you need to
> add
> to your code:
>
> Dim crParameterFields As ParameterFields
> Dim crParameterField As ParameterField
> Dim crParameterValues As ParameterValues
>
> CrViewer.ReportSource = "YourReportLocation"
> crParameterFields = CrViewer.ParameterFieldInfo
>
> crParameterField = crParameterFields.Item("YourCRParameterName")
> crParameterValues = crParameterField.CurrentValues
> crParameterDiscreteValue = New ParameterDiscreteValue
> crParameterDiscreteValue.Value = YourParameterValue
> crParameterValues.Add(crParameterDiscreteValue)
>
> CrViewer.ParameterFieldInfo = crParameterFields
>
> CrViewer is the Crystal Report control on your form.
>
> "Mounilk" wrote:
>
|
|
|
|
|