Crystal Reports/SP.NET question

Daspoo

Regular
Joined
Jan 27, 2003
Messages
99
Location
Fort Walton Beach, Florida
Crystal Reports/ASP.NET question

Hey all. I've got an ASP.NET project going here based on loading a crystal report and viewing it using the Crystal Reports Web Viewer. I have a question concerning a problem I'm facing...

Has anyone experienced attempting to pass parameters for a report and then handling subreport parameters that are linked to a field for the datasource of the report? In other words, I have a report that is based on a stored procedure, and it also has a subreport which is also based on a stored procedure. The subreport is linked to the main report, i.e., it has a parameter ("?Pm-") that is linked to a field in the main report (and not a main report parameter). Does anyone have any ideas how to handle passing a value to this linked parameter, or do you not have to do so? I'm a bit clueless here. I've played around with the issue, but I end up with the following error message each time I attempt to pass parameters and view the report:
==============================================
Server Error in '/WebAppCrystalRevisit' Application.
------------------------------------------------------------------

Error in File c:\Reports\CpyInventoryCtrl.rpt: Operation illegal on linked parameter.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldException: Error in File c:\Reports\CpyInventoryCtrl.rpt: Operation illegal on linked parameter.

Source Error:


Line 176:
Line 177: 'Apply the parameter value to the report document (** exporting **)
Line 178: rptDoc.DataDefinition.ParameterFields(pNumber).ApplyCurrentValues(currValues)
Line 179:
Line 180: End Sub


Source File: c:\inetpub\wwwroot\WebAppCrystalRevisit\CrystalObjectClass.vb Line: 178

Stack Trace:

[ParameterFieldException: Error in File c:\Reports\CpyInventoryCtrl.rpt:
Operation illegal on linked parameter.]
.K(String 
, EngineExceptionErrorID  )
.F(Int16 , Int32 )
.E(Int16 )
CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition.ApplyCurrentValues(ParameterValues currentValue)
WebAppCrystalRevisit.CrystalObjectClass.SetParameter(Int32 pNumber, String dValue) in c:\inetpub\wwwroot\WebAppCrystalRevisit\CrystalObjectClass.vb:178
WebAppCrystalRevisit.frmParameters.Proceed(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebAppCrystalRevisit\frmParameters.aspx.vb:290
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

------------------------------------------------------------------
Version Information:
Microsoft .NET Framework Version:1.0.3705.288;
ASP.NET Version:1.0.3705.288
==============================================

Any assistance with this would be most appreciated! Thanks in advance.

P.S. - I've posted the same question in the Crystal Decisions forum for Crystal Reports for VS.NET...
:D
 
Last edited:
Matt_I:

Yeah, I finally got it working. Basically, the only thing I had to do was this:

==========================================
If rptDoc.DataDefinition.ParameterFields.Item(j).IsLinked = False Then
rptDoc.DataDefinition.ParameterFields.Item(j).ApplyCurrentValues(rptDoc.DataDefinition.ParameterFields.Item(k).CurrentValues)
End If
==========================================

I check to see if the parameter is a linked parameter, and if it is, I do nothing; if it is not, I pass the current value to it. Hope that makes sense. Thanks!
 
Same Problem

Thanks!

I tried it, and now I've got a new error. When I go to export the report (to PDF in this case) I get a ParameterField error. Basically, I think it's saying that the parameter isn't set.

Any idea on that one?
 
Hmmm...well, there's something you could look at after setting all of the parameter field values for the report. When you get to the line which begins the export (i.e., "rptDoc.Export" where rptDoc is the report document object), set a breakpoint there and look at the following:

rptDoc.DataDefinition.ParameterFields(pNumber).HasCurrentValue,

where pNumber can either be the parameter number in the count of all parameters ***rptDoc.DataDefinition.ParameterFields(pNumber).Count***

Basically, when your code hits the breakpoint at the .Export line of code, go to your "Immediate" (Command) window and type in the above line for each parameter in the report. If the expression evaluates True, then that param is set; if it's false, there's the param that's not set, and maybe you'll find something in your code that will stand out to help you fix it. Hope that helps!
 
I may want to suggest one solution which I tried and it worked. Instead of checking islinked and all those things, we can remove the links between main report and sub report in the rpt file and pass the values to all the parameters (includes sub-report parameters) from the front-end to the report. It will work for sure without any errors.

Try this and let me know if you hav any issues.
 
Back
Top