problem passing parameters to crystal reports 
Author Message
 problem passing parameters to crystal reports

I'm trying to display some Crystal Reports used by the customer
service dept. in a web application.  If the report has no parameters,
the report shows up just fine using CrystalReportViewer.  However,
when I try to assign values to a parameter based report, i get the
error "Missing parameter field current value."
This is my first time working with Crystal Reports in ASP or ASP.Net,
so I'm not sure if i'm on the right track or way out in right field...

my code is below....any help/insight would be appreciated.  Reply to

if(Page.IsPostBack)
{                      
        ParameterField param1 = new ParameterField();
        ParameterField param2 = new ParameterField();
        ParameterField param3 = new ParameterField();
        ParameterField param4 = new ParameterField();

        param1.ParameterFieldName = "StartDate";
        param2.ParameterFieldName = "EndDate";
        param3.ParameterFieldName = "StartUser";
        param4.ParameterFieldName = "EndUser";

        ParameterDiscreteValue param1Val = new ParameterDiscreteValue();
        ParameterDiscreteValue param2Val = new ParameterDiscreteValue();
        ParameterDiscreteValue param3Val = new ParameterDiscreteValue();
        ParameterDiscreteValue param4Val = new ParameterDiscreteValue();

        param1Val.Value = startDate.Text;
        param2Val.Value = endDate.Text;
        param3Val.Value = startUser.Text;
        param4Val.Value = endUser.Text;

        param1.CurrentValues.Add(param1Val);
        param2.CurrentValues.Add(param2Val);
        param3.CurrentValues.Add(param3Val);
        param4.CurrentValues.Add(param4Val);

        ParameterFields paramFields = new ParameterFields();

        paramFields.Add(param1);
        paramFields.Add(param2);
        paramFields.Add(param3);
        paramFields.Add(param4);

        CrystalReportViewer1.ParameterFieldInfo = paramFields;

        CrystalReportViewer1.ReportSource =
"c:\\inetpub\\csreports\\crystal\\dailyprod.rpt";
        CrystalReportViewer1.DataBind();

Quote:
}



Sun, 07 Aug 2005 09:46:07 GMT  
 problem passing parameters to crystal reports
I do not know if this will help but I use this code in vb6.
Public rptParamDefs As CRPEAuto.ParameterFieldDefinitions
Public rptParamDef As CRPEAuto.ParameterFieldDefinition
        Set rptParamDefs = Report.ParameterFields
        For Each rptParamDef In rptParamDefs
        With rptParamDef
        If .ParameterFieldName = "Beginning_Date" Then
            .SetCurrentValue (CDate(dBeginDate))
        ElseIf .ParameterFieldName = "Ending_Date" Then
            .SetCurrentValue (CDate(dEndDate))
        Else
            Screen.MousePointer = 0
            frmParameter.Show 1, Me
            Screen.MousePointer = 11
        End If
        End With

--

Regards,

Michael Holzemer
*************
Reply in newsgroup only please
*************


Quote:
> I'm trying to display some crystal reports used by the customer
> service dept. in a web application.  If the report has no parameters,
> the report shows up just fine using CrystalReportViewer.  However,
> when I try to assign values to a parameter based report, i get the
> error "Missing parameter field current value."
> This is my first time working with Crystal Reports in ASP or ASP.Net,
> so I'm not sure if i'm on the right track or way out in right field...

> my code is below....any help/insight would be appreciated.  Reply to

> if(Page.IsPostBack)
> {
> ParameterField param1 = new ParameterField();
> ParameterField param2 = new ParameterField();
> ParameterField param3 = new ParameterField();
> ParameterField param4 = new ParameterField();

> param1.ParameterFieldName = "StartDate";
> param2.ParameterFieldName = "EndDate";
> param3.ParameterFieldName = "StartUser";
> param4.ParameterFieldName = "EndUser";

> ParameterDiscreteValue param1Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param2Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param3Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param4Val = new ParameterDiscreteValue();

> param1Val.Value = startDate.Text;
> param2Val.Value = endDate.Text;
> param3Val.Value = startUser.Text;
> param4Val.Value = endUser.Text;

> param1.CurrentValues.Add(param1Val);
> param2.CurrentValues.Add(param2Val);
> param3.CurrentValues.Add(param3Val);
> param4.CurrentValues.Add(param4Val);

> ParameterFields paramFields = new ParameterFields();

> paramFields.Add(param1);
> paramFields.Add(param2);
> paramFields.Add(param3);
> paramFields.Add(param4);

> CrystalReportViewer1.ParameterFieldInfo = paramFields;

> CrystalReportViewer1.ReportSource =
> "c:\\inetpub\\csreports\\crystal\\dailyprod.rpt";
> CrystalReportViewer1.DataBind();
> }



Sun, 07 Aug 2005 09:51:52 GMT  
 problem passing parameters to crystal reports


Quote:
> I'm trying to display some crystal reports used by the customer
> service dept. in a web application.  If the report has no parameters,
> the report shows up just fine using CrystalReportViewer.  However,
> when I try to assign values to a parameter based report, i get the
> error "Missing parameter field current value."
> This is my first time working with Crystal Reports in ASP or ASP.Net,
> so I'm not sure if i'm on the right track or way out in right field...

> my code is below....any help/insight would be appreciated.  Reply to

> if(Page.IsPostBack)
> {
> ParameterField param1 = new ParameterField();
> ParameterField param2 = new ParameterField();
> ParameterField param3 = new ParameterField();
> ParameterField param4 = new ParameterField();

> param1.ParameterFieldName = "StartDate";
> param2.ParameterFieldName = "EndDate";
> param3.ParameterFieldName = "StartUser";
> param4.ParameterFieldName = "EndUser";

> ParameterDiscreteValue param1Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param2Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param3Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param4Val = new ParameterDiscreteValue();

> param1Val.Value = startDate.Text;
> param2Val.Value = endDate.Text;
> param3Val.Value = startUser.Text;
> param4Val.Value = endUser.Text;

> param1.CurrentValues.Add(param1Val);
> param2.CurrentValues.Add(param2Val);
> param3.CurrentValues.Add(param3Val);
> param4.CurrentValues.Add(param4Val);

> ParameterFields paramFields = new ParameterFields();

> paramFields.Add(param1);
> paramFields.Add(param2);
> paramFields.Add(param3);
> paramFields.Add(param4);

> CrystalReportViewer1.ParameterFieldInfo = paramFields;

> CrystalReportViewer1.ReportSource =
> "c:\\inetpub\\csreports\\crystal\\dailyprod.rpt";
> CrystalReportViewer1.DataBind();
> }

Here is the ASP code I use to send the parameters passed to the report:
Hope it helps.

set ParameterFieldsCollection = Session("oRpt").ParameterFields
  for each Parameterfields in ParameterFieldsCollection
   Set Param = Parameterfields
    'response.write Parameterfields.Name
   ParamValue = Request.Form(Parameterfields.Name)
    'response.write Request.Form(Parameterfields.Name)
   Call param.ClearCurrentValueAndRange
    'Call Param.SetCurrentValue (ParamValue)
   Select Case  Param.ValueType
   Case 7,8 '7=Number, 8 = currency
      Call Param.AddCurrentValue(CDbl(Request.Form(Parameterfields.Name)))
   Case 9  '9 = boolean
    Call Param.AddCurrentValue(CBool(Request.Form(Parameterfields.Name)))
   Case 10,11 '10 = date 11 = time
    Call Param.AddCurrentValue(CDate(Request.Form(Parameterfields.Name)))
   Case 12 '12 = string
    Call Param.AddCurrentValue(CStr(Request.Form(Parameterfields.Name)))
   Case 14 ' 14 = PersistentMemo
    Call Param.AddCurrentValue(CStr(Request.Form(Parameterfields.Name)))
   Case 15 ' 15 = BLOB
    Call Param.AddCurrentValue(CStr(Request.Form(Parameterfields.Name)))
   Case Else
    Call Param.AddCurrentValue(CStr(Request.Form(Parameterfields.Name)))
   End Select
  Next



Sun, 07 Aug 2005 14:16:14 GMT  
 problem passing parameters to crystal reports
Hmmm. I don't see where the problem is. Have you tried inspecting the
reports existing parameter collection and checking the names to make sure
they match up? (after assigning the ReportSource property browse the
object's properties).

Wait - I see you calling DataBind() on the Viewer. You should do this prior
to setting the parameters. In fact you probably don't have to call it at all
(what are you binding to?). Take out the Databind() and let me know what
happens.

A Crystal Reports.NET book for programmers? Its free!
* Covers ASP.NET and Windows Forms
* Teaches all phases of report development
* Alerts you to the bugs and how to get around them
* Maps out the complex ReportDocument object model
* Shows how to perform runtime customization
* Demonstrates all options of connecting with ADO.NET
* Gives complete code listings for every concept presented

www.CrystalReportsBook.com?cpgn=ngcr_021803

HTH,

Brian Bischof
 Moving from VB6 to VB.NET?  It just got easier...
 "The .NET Languages: A Quick Translation Guide"
 http://www.amazon.com/exec/obidos/ASIN/1893115488


Quote:
> I'm trying to display some crystal reports used by the customer
> service dept. in a web application.  If the report has no parameters,
> the report shows up just fine using CrystalReportViewer.  However,
> when I try to assign values to a parameter based report, i get the
> error "Missing parameter field current value."
> This is my first time working with Crystal Reports in ASP or ASP.Net,
> so I'm not sure if i'm on the right track or way out in right field...

> my code is below....any help/insight would be appreciated.  Reply to

> if(Page.IsPostBack)
> {
> ParameterField param1 = new ParameterField();
> ParameterField param2 = new ParameterField();
> ParameterField param3 = new ParameterField();
> ParameterField param4 = new ParameterField();

> param1.ParameterFieldName = "StartDate";
> param2.ParameterFieldName = "EndDate";
> param3.ParameterFieldName = "StartUser";
> param4.ParameterFieldName = "EndUser";

> ParameterDiscreteValue param1Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param2Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param3Val = new ParameterDiscreteValue();
> ParameterDiscreteValue param4Val = new ParameterDiscreteValue();

> param1Val.Value = startDate.Text;
> param2Val.Value = endDate.Text;
> param3Val.Value = startUser.Text;
> param4Val.Value = endUser.Text;

> param1.CurrentValues.Add(param1Val);
> param2.CurrentValues.Add(param2Val);
> param3.CurrentValues.Add(param3Val);
> param4.CurrentValues.Add(param4Val);

> ParameterFields paramFields = new ParameterFields();

> paramFields.Add(param1);
> paramFields.Add(param2);
> paramFields.Add(param3);
> paramFields.Add(param4);

> CrystalReportViewer1.ParameterFieldInfo = paramFields;

> CrystalReportViewer1.ReportSource =
> "c:\\inetpub\\csreports\\crystal\\dailyprod.rpt";
> CrystalReportViewer1.DataBind();
> }



Sun, 07 Aug 2005 14:24:00 GMT  
 problem passing parameters to crystal reports
Thanks for the responses.  I double checked the parameter names, even
output them to the screen to make sure they match up.  I also tried
taking out the call to DataBind() but i still get the same error.  One
thing i didn't mention is that this is an old report converted from
crystal 7.0.

I may try rewriting the report from scratch or dumping crystal
altogether and just use asp.net and ado.net to create a web version of
the report.

p.s.  Brian, your site was one of the more useful resources i've found
so far for working with CR and .NET  I hope the demand comes back and
you get a chance to finish and publish it.



Mon, 08 Aug 2005 04:01:29 GMT  
 problem passing parameters to crystal reports
Thanks for the comments about the book. I hope to get it on the shelves one
day... I don't know if CR 7 has anything to do with it. I haven't tried that
yet. But its definitely worth a shot to redo it in CR.NET.

Good luck.

A Crystal Reports.NET book for programmers? Its free!
* Covers ASP.NET and Windows Forms
* Teaches all phases of report development
* Alerts you to the bugs and how to get around them
* Maps out the complex ReportDocument object model
* Shows how to perform runtime customization
* Demonstrates all options of connecting with ADO.NET
* Gives complete code listings for every concept presented

www.CrystalReportsBook.com?cpgn=ngcr_021803

Brian Bischof
 Moving from VB6 to VB.NET?  It just got easier...
 "The .NET Languages: A Quick Translation Guide"
 http://www.amazon.com/exec/obidos/ASIN/1893115488


Quote:
> Thanks for the responses.  I double checked the parameter names, even
> output them to the screen to make sure they match up.  I also tried
> taking out the call to DataBind() but i still get the same error.  One
> thing i didn't mention is that this is an old report converted from
> crystal 7.0.

> I may try rewriting the report from scratch or dumping crystal
> altogether and just use asp.net and ado.net to create a web version of
> the report.

> p.s.  Brian, your site was one of the more useful resources i've found
> so far for working with CR and .NET  I hope the demand comes back and
> you get a chance to finish and publish it.



Mon, 08 Aug 2005 04:19:17 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Passing Parameters from C# to Crystal Report / Crystal Report Viewer

2. Problem with VB passing parameters to Crystal Report - Stored Procedure

3. vb problems - parameter passing to crystal reports

4. Passing parameters to a report in Crystal Reports 6

5. parameter passing to Crystal Reports 9

6. Passing parameters to crystal report

7. Passing a parameter to Crystal Reports

8. How do you pass parameters from VB 5 to crystal reports

9. Passing parameters to Crystal Reports

10. Passing Parameters to Crystal Report 5.0 (Stored Procedure Query )

11. Passing parameter to Crystal Reports

12. Pass parameters to Crystal Reports?

 

 
Powered by phpBB® Forum Software