I designed a simple database in c# win form. Database has only one table in it(workers), with columns(name, adress, city...).
Then I drag my table(workers) to win form, and want to make query in textbox1.
What I want is to have textbox with label near him that say "search by city", and when I type the name of city and press enter all records with that city appear on my form.
Problem starts when I right click my table(workers) in data sources>edit dataset>add query>query builder.
Can you tell me the next step when I open the query builder.
I know the code for textbox. It goes something like this:
if (e.KeyCode == Keys.Enter)
{
this.personsTableAdapter.onlyCity(this.workersDataSet.persons, textBox1.Text);
}
Thank you very much for your help.
Josip
Loading
Sam HobbsPosted Nov 29, 2011, 2:25 PM
I assume you have created a data source using the Data Sources window. In that data source, include the city but do not include a filter; in other words, do not use the SQL in the data source to select a city. So then when you drag the data source to the form, it will create a DataGridView that shows all records.
Then next to textBox1 create a button and in the button click event take textBox1.Text and put it into the
BindingSource.Filter Property for the table; something like:
It might take a few minutes to figure all that out but after doing it the first time it will require just a few seconds to do it in the future.
Josip PavicPosted Nov 29, 2011, 2:27 PM