Hi!!!

I have made a window application with MS access database to analysis student performance in his class for each exam that he appeared for.

I have a table named result with following fields:

classname,sectionname,subjectname,exam type,rollno,studentname and marks.

On one form I have taken crystal reportviewer and 5 comboboxes for selecting class,section, subject, exam(first,second,final or unit tests), and student name.

After selecting these values , click on button to generate graph of his marks for each exam.

I was able to generate graph for one student for any particular class and section.

But the problem is that the graph is not generating for for other exams and other students.

My code is able to give graph for one student and not for other.

Please check the parameter type/value.

I have set the parameter values through code and it is as follows:

ReportDocument cryRpt = new ReportDocument();
                cryRpt.Load("D:\\SchoolManagementSystem\\School\\@forms\\CrystalReport.rpt");
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
    //******************------------ Class Selection  ----------------*****************************
                crParameterDiscreteValue.Value = comboBox1.Text.ToString();
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["c_name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
    //******************------------ Section Selection  ----------------*******************************************
                crParameterValues.Clear();
                crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = comboBox2.Text.ToString();
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["sec_name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                //crystalReportViewer1.ReportSource = cryRpt;
    //******************------------ Examination Selection  ----------------****************************************
                crParameterValues.Clear();
                crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = comboBox4.Text.ToString();
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["e_name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
    //******************------------ Subject Selection  ----------------*********************************************
                cls_Con.cn.Open();
                crParameterValues.Clear();

                OleDbCommand cmd = new OleDbCommand("select sub_name from [subject] where c_id=" + c_id + " and sec_id=" + id + "", cls_Con.cn);
                OleDbDataReader dr = cmd.ExecuteReader();
                crParameterFieldDefinition = crParameterFieldDefinitions["sub_name"];
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                while (dr.Read())
                {
                    crParameterDiscreteValue = new ParameterDiscreteValue();
                    crParameterDiscreteValue.Value = dr.GetValue(0);
                    crParameterValues = crParameterFieldDefinition.CurrentValues;
                    crParameterValues.Add(crParameterDiscreteValue);
                    //MessageBox.Show(""+crParameterDiscreteValue.Value);
                }
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                cls_Con.cn.Close();
                // crystalReportViewer1.ReportSource = cryRpt;
   //******************------------ Year Selection  ----------------**************************************************
                crParameterValues.Clear();
                crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = comboBox5.Text.ToString();
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["s_year"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
   //******************------------ Student Selection  ----------------
                crParameterValues.Clear();
                crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = comboBox6.Text.ToString().Trim();
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["s_name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
   //******************------------ Marks Selection  ----------------
                cls_Con.cn.Open();
                crParameterValues.Clear();
                OleDbCommand cmd1 = new OleDbCommand("select marks from [result] where c_id=" + c_id + " and sec_id=" + id + " and s_id=" + s_id + " and e_id=" + e_id + " and s_year='" + comboBox5.Text.ToString() + "'", cls_Con.cn);
                OleDbDataReader dr1 = cmd1.ExecuteReader();
                crParameterFieldDefinition = crParameterFieldDefinitions["s_marks"];
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                while (dr1.Read())
                {
                    crParameterDiscreteValue = new ParameterDiscreteValue();
                   // MessageBox.Show(" data   " + dr1.GetValue(0));
                    crParameterDiscreteValue.Value = Int32.Parse(dr1.GetValue(0).ToString());
                    //MessageBox.Show("" + crParameterDiscreteValue.Value);
                    crParameterValues = crParameterFieldDefinition.CurrentValues;
                    crParameterValues.Add(crParameterDiscreteValue);
                    
                }
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                cls_Con.cn.Close();
                //MessageBox.Show("" +crParameterDiscreteValue.Value);
                

  //------------  All Data to Report  ----------------
                crystalReportViewer1.ReportSource = cryRpt;
                crystalReportViewer1.Refresh();
            }

plz give some solution........................:sad:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.