TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chidiebere Mgbemena
NA
179
14.2k
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.
private
void
btnSave_Click(
object
sender, EventArgs e)
{
// delete old bills details from Row data
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);
}
// now save updated Bill data
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);
}
// now update bill amount, discount and final amount
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);
}
}
}
}
Reply
Answers (
4
)
How to make deployment of .Net core console application
Mobile apps development using C#