If a textbox value has changed, how can I select from a database by the new textbox value and not the old value?
string constring = "datasource=127.0.0.1;username=root;password=admin";
string Query = "select * from mohamed.usercompany1 where office = '" + textBox1.Text + "' ;";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase);
DataSet DataSet1 = new DataSet();
MySqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
if (myReader.Read())
{
string scode = myReader.GetInt32("techname").ToString();
textBox1.Text = (string)myReader["techname"];
comboBox2.Items.Add(scode).ToString();
listView1.Items.Add(scode).ToString();
this.Refresh();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}