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.
- private void btnSave_Click(object sender, EventArgs e)
- {
-
- try
- {
- con.Open();
- cmd = new SqlCommand("Delete from Tbl_RowData where JobNo = '" + txtJobNo.Text + "'", con);
- cmd.ExecuteNonQuery();
- con.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
-
- try
- {
- for(int i = 0; i < dataGridView1.Rows.Count; i++)
- {
- 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);
- con.Open();
- cmd1.ExecuteNonQuery();
- con.Close();
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
-
- try
- {
- con.Open();
- 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);
- cmd.ExecuteNonQuery();
- con.Close();
- MessageBox.Show("Bill Updated");
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }