Link to home
Start Free TrialLog in
Avatar of SunDevilProgrammer
SunDevilProgrammer

asked on

Programmatically adding crystal report parameters in web page(ASP.NET)

I would like to add parameters to filter based on user's selection.  I have used a stored procedure to load the crystal report.  The parameter is the same as the input parameter used in the stored proc.  For some reason the report does not allow any parameter choosing option on the web page, while it executes just fine when I run the report by itself (as a Crystal report).  

Thanks,

SunDevil
Avatar of Mike McCracken
Mike McCracken

It should prompt for the stored procedure parameter.

Is the parameter simply for filtering?

Yes, you can pass parameters to the report from an ASP page.

Display the FIELD EXPLORER
Right Click PARAMETER
Click NEW
FIll in the form

Save it

CLick REPORT
CLICK SELECT EXPERT
Select the field
Select the comparison
Select the parameter

mlmcc
Avatar of SunDevilProgrammer

ASKER

I did all of that but still am not prompted for a value when I run the app.  I get the report for the same parameter value every time and does not allow me to chcange the parameter value.  The purpose of using a parameter seems to be lost.  I am assuming I have to programmatically include the parameter option.  Something like..."ParameterFields"  or something of the sort...

HELP!!
Do you have the report saved with data?
Open the report
Click FILE
Ensure SAVE DATA WITH REPORT is not checked.

Try hitting the REFRESH button on the viewer.

mlmcc
I have done everything described and am now getting an error that says "List of Values Failure. Fail to get values. Cause of Error: [Length of parameter field current values must be less than or equal to the maximum value.]"

The DataType of the field i sVarchar2(15Byyte) and I have no way to modify this.

Thanks
SunDevil
Also, I would liek to mention here that although the parameter, when set to be Dynamic, produces the said error, but when set to Static, works just fine.  But I would like for the parameter field to get populated from the database and not let the user type in the values.

Woudl I be able to do it using VB code in the ASP page?
If you want it to be populated from the database you have to ensure all values in the database match the parameter type.

mlmcc
The dtabase has a VARCHAR2 datatype, but the only equivalent datatype in the parameter definition form is the String.  Is this what you are referring to?  Also, I noticed a snippet requiring to instantiate the report object as ..
Dim MyReport as new CrystalReport1
I want to know if "CrystalReport1" in this context is teh name of the report I created.  

I am sorry to be confused over an issue that is rather simple.  But the fact that this is so eluding tells it is not a simple problem anymore.  But with your help, it should be!

SunDevil

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Code that worked:
In the Load event of the page...

Dim Report as New ReportDocument()
Report.Load("C:\Documents and Settings\MyReport")
Report.SetDatabaseLogon("username", password")
CrystalReportViewer1.ReportSource = Report

I still need clarification on SetParameterValue method.

Is it necessary to go through the process in the report creation phase and still declare programmatically or can you avoid setting it in the report and directly code in the code-behind page?

Thanks,

SunDevil