I'm trying to get some more user friendly things in my program done. Now I'm trying to filter by typing in a text box and it filters to what you are typing and shows the entire row.
This is what I currently have:
Expand|Select|Wrap|Line Numbers
- private void txtFilter_TextChanged(object sender, EventArgs e)
- {
- try
- {
- SQLiteConnection connect = new SQLiteConnection(connString);
- connect.Open();
- string whereQuery = "select Channel from Test where Channel '" + txtFilter.Text + "'";
- SQLiteDataAdapter adap = new SQLiteDataAdapter(whereQuery, connString);
- DataSet ds2 = new DataSet();
- adap.Fill(ds2);
- dataGridView1.DataSource = ds2.Tables[0];
- }
- catch (Exception ex)
- {
- MessageBox.Show("An error occured.\n" + ex.ToString(),"Error!");
- }
- }
Expand|Select|Wrap|Line Numbers
- SQLite error
- near "'N'": syntax error
I don't exactly get what I've done wrong.
Any help would be much appreciated. Thanks
EDIT:
Ok, so I've edited the code now to this:
Expand|Select|Wrap|Line Numbers
- private void txtFilter_TextChanged(object sender, EventArgs e) // FILTER TODO
- {
- DataView view = new DataView();
- SQLiteConnection connect = new SQLiteConnection(connString);
- connect.Open();
- view.RowFilter = "Channel like '%" + txtFilter.Text + "%'";
- }