Use combobox value as query value (VC# 2k8 / ADO SQLITE)

Posted by nicodevil on Stack Overflow See other posts from Stack Overflow or by nicodevil
Published on 2010-05-24T21:23:57Z Indexed on 2010/05/24 21:31 UTC
Read the original article Hit count: 140

Filed under:
|
|

Hi, I'm a newbie in VC# and ADO SQLITE...

I'm trying to change the content of a combobox according to the value present in another one...

My problem is here :

SQLiteCommand cmd3 = new SQLiteCommand("select distinct(ACTION) from ACTION_LIST where CATEGORY='comboBox1.text'", conn2);

What to use to do the job ? Here 'comboBox1.text' is see as a sentence not a variable...

Here is the code :

 private void Form1_Load(object sender, EventArgs e)
        {
            using (SQLiteConnection conn1 = new SQLiteConnection(@"Data Source = Data\MRIS_DB_MASTER"))
            {
                conn1.Open();
                SQLiteCommand cmd2 = new SQLiteCommand("select distinct(CATEGORY) from ACTION_LIST", conn1);
                SQLiteDataAdapter adapter1 = new SQLiteDataAdapter(cmd2);
                DataTable tbl1 = new DataTable();
                adapter1.Fill(tbl1);
                comboBox1.DataSource = tbl1;
                comboBox1.DisplayMember = "CATEGORY";
                adapter1.Dispose();
                cmd2.Dispose();
            }

            using (SQLiteConnection conn2 = new SQLiteConnection(@"Data Source = Data\MRIS_DB_MASTER"))
            {
                conn2.Open();
                SQLiteCommand cmd3 = new SQLiteCommand("select distinct(ACTION) from ACTION_LIST where CATEGORY='comboBox1.text'", conn2);
                SQLiteDataAdapter adapter2 = new SQLiteDataAdapter(cmd3);
                DataTable tbl2 = new DataTable();
                adapter2.Fill(tbl2);
                comboBox2.DataSource = tbl2;
                comboBox2.DisplayMember = "ACTION";
                adapter2.Dispose();
                cmd3.Dispose();
            }
        }

Thanks

regards

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlite