title: Inserting values from datagridview into SQL Server database in C#
body: <p>I have two tables in a SQL Server database, <code>product</code> and <code>innvoice</code>.</p>
  
  <p>I am fetching selected data from table <code>product</code> and showing them in datagridview.</p>
  
  <p>Now I want to store data from datagridview to table <code>innvoice</code>. This all operation takes on one button click.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>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.
  }
  </code></pre>