Error in SqlCommand

Jun 5 2020 3:29 PM
Hello Guys,
 
Please i have error on the underlined "cmd = new SqlCommand"
 
here is the error message;
 
Sql command.SqlCommand() (+ 3 overload) initialize a new instance of the SlqCommand class. ‘SqlCommand’ does not contain a constructor that takes 8 arguments
 
what constructor can i use to clear the error?
 
Thank you.
  1. private void btnSave_Click(object sender, EventArgs e)  
  2. {  
  3. // delete old bills details from Row data  
  4. try  
  5. {  
  6. con.Open();  
  7. cmd = new SqlCommand("Delete from Tbl_RowData where JobNo = '" + txtJobNo.Text + "'", con);  
  8. cmd.ExecuteNonQuery();  
  9. con.Close();  
  10. }  
  11. catch (Exception ex)  
  12. {  
  13. MessageBox.Show(ex.Message);  
  14. }  
  15. // now save updated Bill data  
  16. try  
  17. {  
  18. for(int i = 0; i < dataGridView1.Rows.Count; i++)  
  19. {  
  20. SqlCommand cmd1 = new SqlCommand("Insert into Tbl_RowData(SINO,Customer,DescriptionPrice,Quantity,Value,JobNo,Date)values('" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[3].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[4].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[5].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[6].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[7].Value.ToString() + "')", con);  
  21. con.Open();  
  22. cmd1.ExecuteNonQuery();  
  23. con.Close();  
  24. }  
  25. }  
  26. catch(Exception ex)  
  27. {  
  28. MessageBox.Show(ex.Message);  
  29. }  
  30. // now update bill amount, discount and final amount  
  31. try  
  32. {  
  33. con.Open();  
  34. cmd = new SqlCommand("Update Tbl_HeaderData set Date= '" + dateTimePicker1.Value.ToString("dd/MM/yyyy")+ "', GoodValue= '",txtTotalGoodValue.Text +"', Vat = '", txtVat.Text+"', StampDuty='", txtStampDuty.Text+"',DeliveryCharges='", txtDeliveryCharges.Text+"', OtherCharges='",txtOtherCharges.Text+"', Total= '", txtTotal.Text+"'", con);  
  35. cmd.ExecuteNonQuery();  
  36. con.Close();  
  37. MessageBox.Show("Bill Updated");  
  38. }  
  39. catch(Exception ex)  
  40. {  
  41. MessageBox.Show(ex.Message);  
  42. }  
  43. }  
  44. }  
  45. }

Answers (4)