我在 SQL Server 数据库中有两个表,product
并且innvoice
.
我正在从表中获取选定的数据product
并在 datagridview 中显示它们。
现在我想将数据从 datagridview 存储到 table innvoice
。这一切操作只需单击一下按钮。
这是我的代码:
private void button5_Click_2(object sender, EventArgs e) //add produt
{
SqlConnection con = new SqlConnection(@"Persist Security Info=False;User ID=usait;password=123;Initial Catalog=givenget;Data Source=RXN-PC\ROSHAAN");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT product.p_name,product.p_category, product.sale_price FROM product where p_code='" + textBox16.Text + "'", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView3.DataSource = dt;
// here I want to insert values from datagridview3 to table innvoice.
}