Hey all,
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:
I get an exception error though:
// N is what I started typing to start the filter.
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:
No more exception errors, just not what I want it to do. It just keeps everything there. Any ideas?
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:
Code:
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!");
}
}
Code:
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:
Code:
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 + "%'";
}
Comment