我想将quantity
我的数据库中的列放在 datagridview 中,其中首先加载了数据,5 列与 column 一起quantity
。现在我尝试quantity
在我的数据库中加载该列。这是我的代码:
using (MySqlConnection con = new MySqlConnection(serverstring))
{
string query = @"SELECT quantity
FROM tblOrder_Products
WHERE order_ID=@ID";
con.Open();
using (MySqlCommand cmd = new MySqlCommand(query, con))
{
DataTable dt = new DataTable();
cmd.Parameters.AddWithValue("@ID", txtboxID.Text);
MySqlDataReader dr = cmd.ExecuteReader();
dt.Load(dr);
dr.Close();
dataGridView2.DataSource = dt;
// I want to change this line or this part of code because
// I want to put only the column `quantity` which means
//retaining the data loaded previously in the datagridview
}
所以我的问题是我将如何将它放入 datagridview 而不删除或覆盖之前加载的数据?