rashmi kc

rashmi kc

  • NA
  • 113
  • 159.2k

combobox syntax

Jul 15 2012 12:11 PM
I am getting an error like Syntax error (comma) in query expression 'marks,chaptername='2''Electromagnetic Induction''.  

what query i should write to select from both combomarks and combochapters  and display the set of questions the particular chapters accoding to the marks selected  in c#?

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            checkedListBox2.Items.Clear();
            //cmbosubject.Items.Clear();
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\easyexamdb.mdb");
            con.Open();
            str = "select * from tblmcq where marks,chaptername='" + comboBox1.Text + "''" + checkedListBox1.SelectedItem + "'";
            com = new OleDbCommand(str, con);
            OleDbDataReader reader = com.ExecuteReader();
            while (reader.Read())
            {
                checkedListBox2.Items.Add(reader["question"]); //.ToString());
            }
            con.Close();
            reader.Close();
}




Answers (4)