I want to put the column quantity
from my database in the datagridview which in the first place has data loaded in it, 5 columns together with the column quantity
. Now I tried to load the column quantity
in my database. Here is my code:
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
}
So my question is how am I going to put it in the datagridview without deleting or overwriting the previous one loaded in it?