Whatsup.
At the moment I'm using this code to filter results from my database file when I type text into my textbox:
Does anybody know a faster way to filter the results based on the text entered in the textbox?
At the moment I'm using this code to filter results from my database file when I type text into my textbox:
Code:
listBox1.Items.Clear();
string sqlstring = "SELECT * FROM [thetable] WHERE [question] LIKE '%" + textBox1.Text + "%' or [answer] LIKE '%" + textBox1.Text + "%'";
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=answers.mdb");
DataSet ds = new DataSet("mydataset");
OleDbDataAdapter adapter = new OleDbDataAdapter(sqlstring, connection);
adapter.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
listBox1.Items.Add("[" + Convert.ToString(dr["answer"]) + "] " + Convert.ToString(dr["question"]));
}