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

Missing parameter values in asp .net

Former Member
0 Likes
531

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"]);

View Entire Topic
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