通过c#中的文本框值从数据库中选择

问题描述:

你好

如果文本框值已更改,我如何通过新文本框值而不是旧值从数据库中进行选择?

使用c#和MySql

我的代码

hello
If a textbox value has changed, how can I select from a database by the new textbox value , not the old value?
using c# and MySql
my code

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);
}

TextBox有TextChanged事件,当TextChanged触发器再次调用该方法时。
Hi TextBox has TextChanged event,when the TextChanged trigger,can invoke again the method.

文本更改事件中的

逻辑