vinni jain

vinni jain

  • NA
  • 111
  • 0

Error: No Value Given For One Or More Required Parameters

Feb 16 2010 12:33 AM

Hi!!!

I am making a school management application using visual studio2008, MS Access database, C#.
There are two tables: "class" with fields c_id , c_name
"section" with fields c_name , sec_id, sec_name.
On the form I have two combobox one for class named "com_Class" and other for section named "com_Section" .I want that when I select any class from "com_Class" then the sections( corresponding to that particular selected class) should display in "com_Section" and not all the sections.

I am using following code :
 cls_Con.comboFill(this.com_Section, "select * from [section] where c_name="+com_Class.SelectedItem.ToString()+"", "[section]", "sec_name", "sec_id");
       

I have a class(clsODBC.cs) for database connectivity and in that I have make function comboFill() and the code is as follows:
 public void comboFill(ComboBox cmb, string strSQL, string dTable, string dDisplay, string dValue)
        {
            try
            {
                cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                //OleDbCommand cmd = new OleDbCommand();
                DataSet ds = new DataSet();
                OleDbDataAdapter da = new OleDbDataAdapter(strSQL, cn);
                da.Fill(ds, dTable);
                cmb.DataSource = ds.Tables[dTable].DefaultView;
                cmb.DisplayMember = dDisplay;
                cmb.ValueMember = dValue;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
In clsODBC.cs, I have written complate code for database connectivity and to access this class in each form I have added following statement in each form:
 _class.clsODBC cls_Con = new School._class.clsODBC();
        OleDbCommand cmdForm = new OleDbCommand();


Kindly provide some solution.........

Answers (1)