刷新WPF应用程序窗口

时间:2014-08-20 04:09:20

标签: c# wpf

我是C#的新手。我试图开发WPF应用程序。在这里,当我按下保存按钮时,我想在将值插入数据库后刷新所有文本框。我怎样才能做到这一点?感谢..

addnewcategory.xaml.cs

    public addnewcategory()
    {
        InitializeComponent();
    }

    private void save_Click(object sender, RoutedEventArgs e)
    {
        string dbConn = "datasource=localhost;port=3306;username=root";
        string Query = "insert into tenderprocess.mstcategory (category) values('" + this.txtcategory.Text + "');";
        MySqlConnection mysqlConn = new MySqlConnection(dbConn);
        MySqlCommand cmdTenderprocess = new MySqlCommand(Query, mysqlConn);
        MySqlDataReader myReader;

        try
        {
            mysqlConn.Open();
            myReader = cmdTenderprocess.ExecuteReader();
            MessageBox.Show("New Category Successfully Saved");
            while (myReader.Read())
            {
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}

}

0 个答案:

没有答案