SQL Server データベースに 2 つのテーブルがありproduct
、innvoice
.
選択したデータをテーブルから取得product
し、datagridview に表示しています。
今、 datagridview から table にデータを保存したいと思いますinnvoice
。このすべての操作は、ボタンを 1 回クリックするだけで完了します。
これが私のコードです:
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.
}