Hi,
Here I am using a code for submit button with the help of this button I want to insert records in two table
1.customer
2.order
Here insert records for customer by text box and product name using by drop down list and rate comes from database I insert quantity from text box on the basis of rate that will calculate and make total_amount and insert records in order table I am using following code.
This code updating only single table
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con=new SqlConnection(ConfigurationManager.AppSettings["connectionstring"].ToString());
SqlCommand cmd;
DataSet ds=new DataSet();
try
{
cmd = new SqlCommand("insert into customer(customer_name,customer_phone,customer_address)values(@customer_name,@customer_phone,@customer_address)", con);
cmd.Parameters.Add("@customer_name", SqlDbType.NVarChar).Value = txtName.Text;
cmd.Parameters.Add("@customer_phone", SqlDbType.NVarChar).Value = TxtPhone.Text;
cmd.Parameters.Add("@customer_address", SqlDbType.NVarChar).Value = txtAddress.Text;
cmd = new SqlCommand("insert into product_order(product_name,product_quantity,product_amount)values(@product_name,@product_quantity,@product_amount)", con);
cmd.Parameters.Add("@product_name", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Text;
cmd.Parameters.Add("@product_quantity", SqlDbType.NVarChar).Value = txtqty.Text;
cmd.Parameters.Add("@product_amount", SqlDbType.NVarChar).Value = txtAmount.Text.ToString();
con.Open();
cmd.ExecuteNonQuery();
Response.Write("yr records updated..");
cmd.Dispose();
}
catch(Exception exe)
{
Response.Write(exe);
}
ds.Dispose();
con.Close();
}