cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Missing parameter values in asp .net

Former Member
0 Likes
530

In database i choose stored procedure, parameter field automatically created and then i remove @ in parameter field,

i used three method searched in asp .net, all failed. Error is missing parameter values.

I have also tried to add back @ also failed

Method 1

// First parameter
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"].ToString();
                crParameterFieldDefinitions = objRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["Cheque_IssueRecord_Secretary_Review_TT_ID"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                // Second parameter
                ParameterFieldDefinitions crParameterFieldDefinitions2;
                ParameterFieldDefinition crParameterFieldDefinition2;
                ParameterValues crParameterValues2 = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue2 = new ParameterDiscreteValue();

                crParameterDiscreteValue2.Value = Request.QueryString["tCOMDB"].ToString();
                crParameterFieldDefinitions2 = objRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition2 = crParameterFieldDefinitions2["tCOMDB"];
                crParameterValues2 = crParameterFieldDefinition2.CurrentValues;

                crParameterValues2.Clear();
                crParameterValues2.Add(crParameterDiscreteValue2);
                crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2);

Method 2

var value = new ParameterDiscreteValue();
                value.Value = Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]);
                objRpt.ParameterFields["Cheque_IssueRecord_Secretary_Review_TT_ID"].CurrentValues.Add(value);

                var value2 = new ParameterDiscreteValue();
                value2.Value = Request.QueryString["tCOMDB"];
                objRpt.ParameterFields["tCOMDB"].CurrentValues.Add(value2);

Method 3

CrystalReportViewer1.ReportSource = objRpt;
                foreach (ParameterField p in CrystalReportViewer1.ParameterFieldInfo) 
                { 
                    //if (Request.QueryString[p.Name]) 
                    //{ 
                        var value = Request.QueryString[p.ToString()]; 
                       if (p.CurrentValues.Count > 0)             
                            ((ParameterDiscreteValue)p.CurrentValues[0]).Value = value; 
                        else             
                            p.CurrentValues.Add(new ParameterDiscreteValue() { Value = value }); 
                    //} 
                }

Methdod4

/

/objRpt.SetParameterValue(0, Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]));
                //objRpt.SetParameterValue(1, Request.QueryString["tCOMDB"]);

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

I solved

objRpt.SetParameterValue(0, Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]));

objRpt.SetParameterValue(1, Request.QueryString["tCOMDB"]);

//The viewer's reportsource must be set to a report before any parameter fields can be accessed.

CrystalReportViewer1.ReportSource = objRpt;

use above code and remove refresh report and setlogondatabase("user", "passwd") then succeed

Former Member
0 Likes

Hello Yeung Lee,

                        Thanks a lot man.

                        Your idea works for me.

Thanks,

Udhay

Answers (3)

Answers (3)

Former Member
0 Likes

After removing refreshreport, it become better.

but error is

The types of the parameter field and parameter field current values are not compatible

i have checked id i passed is convert.toint32 and must be integer, and the rest is string

do not know why have types error

Former Member
0 Likes

After follow csharp_win_rangeparameters, still is missing parameters

objRpt = new ReportDocument();
                string reportPath = Server.MapPath("./Reports/CompanyCode_TT_PrintOut_HP2420_PCL6.rpt");
                objRpt.Load(reportPath);

                //The viewer's reportsource must be set to a report before any parameter fields can be accessed.
                CrystalReportViewer1.ReportSource = objRpt;

                //Get the collection of parameters from the report
                crParameterFields = CrystalReportViewer1.ParameterFieldInfo;

                //Access the specified parameter from the collection
                crParameterField = crParameterFields["Cheque_IssueRecord_Secretary_Review_TT_ID"];

                //Get the current values from the parameter field.  At this point there are zero values set.
                crParameterValues = crParameterField.CurrentValues;

                //Set the current values for the parameter field
                crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"].ToString();

                //Add the first current value for the parameter field
                crParameterValues.Add(crParameterDiscreteValue);

                //Access the specified range parameter from the collection.
                crParameterField2 = crParameterFields["tCOMDB"];

                //Get the current values from the parameter field.  At this point there are zero values set.
                crParameterValues2 = crParameterField2.CurrentValues;

                //Set the current values for the parameter field
                crParameterDiscreteValue2 = new ParameterDiscreteValue();
                crParameterDiscreteValue2.Value = Request.QueryString["tCOMDB"].ToString();

                //Add the current range value for the parameter field
                crParameterValues.Add(crParameterDiscreteValue2);

                /* Set the modified parameters collection back to the viewer so that
                the new parameter information can be used for the report. */
                CrystalReportViewer1.ParameterFieldInfo = crParameterFields;

                CrystalReportViewer1.RefreshReport();

Former Member
0 Likes

See if the samples csharp_win_multirangeparam.zip, csharp_win_paramengine.zip, csharp_win_rangeparameters.zip will help.

You do not mention version of CR or version of .NET - both would be minimal pieces of info, but do make sure you are on the latest SP for your version of CR and that the version of CR is supported in your version of .NET...

- Ludek