Praveen Maurya

Praveen Maurya

  • NA
  • 146
  • 26.8k

transfer value from textbox and a table1 to another table2

Apr 7 2018 8:38 AM
I am trying to enter some data into a table2 from textboxes and some data from A sql databse table1 but all logics gone fail. please help here is the code for your reference.
  1. string qry = "insert into sale (inno,date,type,custname,item,qty,price,dis,disa,gst,gsta,total) values (" + invoice + ",'" + dt + "','" + paytype + "','" + custname + "','" + item + "'," + iqty + "," + iprice + "," + idisc + "," + idsa + "," + igst + "," + igsta + "," + itot + ") and insert into sale (hsn,sgst,cgst) select hsn,sgst,cgst from stock";  
  2. // string qry1 = "";  
  3. // SqlCommand sc1 = new SqlCommand(qry1, con);  
  4. SqlCommand sc = new SqlCommand(qry, con);  
  5. // int j = sc1.ExecuteNonQuery();  
  6. int i = sc.ExecuteNonQuery();  
  7. if (i >= 1)  
  8. MessageBox.Show("Inserted Succesfully");  
  9. else  
  10. MessageBox.Show("Not Done");  

Answers (1)