title: How to insert data into two tables
body: <p>I want to know how to insert data into two different tables.</p>
  
  <p>I have </p>
  
  <p><strong>Orders</strong> table, which has:</p>
  
  <p>OrderID, info, Price, VAT, Customer_ID</p>
  
  <p>and <strong>Customer</strong> table</p>
  
  <p>CustomerID, Name, LastName</p>
  
  <p>Now i want to enter new order, which would have primary key of 1.</p>
  
  <p>How can i write SQL that would enter this order for specific person,..let's say a person who has id of 1 in customer table?</p>
  
  <p>This is what i have so far, but i just can't find solution</p>
  
  <pre><code>using (SqlCommand cmd = new SqlCommand("INSERT INTO [Orders] (info, Price, VAT, Customer_ID) VALUES (@info, @Price, @VAT, @Customer_ID)"))
                  {
                      cmd.Connection = conn;
                      cmd.Parameters.AddWithValue("@info", input1.Text);
                      cmd.Parameters.AddWithValue("@Price", input2.Text);
                      cmd.Parameters.AddWithValue("@VAT", input3.Text);
                      conn.Open();
                      cmd.ExecuteNonQuery();
                  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>i don't want to enter foreign key(id) via textbox, but get it from current logged in user...</p>