I don't know how to do this.
When user bought all products i wanna insert it into Orders table, additionally i wanna insert there customer_id from Customer table where user login = Session["id"]. I tried this but it didn't work :/ What should i do?
protected void ConfirmPurchase_Click(object sender, EventArgs e)
if (Session["id"] != null)
username = Convert.ToString(Session["id"]);
SqlConnection con = new SqlConnection(@"Data Source=SOME_SQL;Initial Catalog=Shop;Integrated Security=True");
SqlCommand cmd = new SqlCommand("INSERT INTO Orders (order_date, paid, transact_status, customer_id) VALUES (GETDATE() ,'" + cost.ToString("c") + "' ,'Przyjęto do bazy', SELECT customer_id FROM Customer WHERE login='" + username + "')", con);
You can try by surrounding the user select with "(" and ")"
SELECT customer_id FROM Customer WHERE login='" + username + "'
( SELECT customer_id FROM Customer WHERE login='" + username + "' )