Hello Guys, my problem is when i insert value database so extra value add in database for example i insert 2 values in db but value insert 3 but sometimes it's insert perfectly but sometimes i am facing extra value issue.
please guys see my code and give me solution of this issue please.
Thank you
What I have tried:
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = @"INSERT INTO Total ([Column1], [Column2], [Column3], [Date], [Receipt No], [Delivery Person], [Report], [Flavours], [Return])
VALUES (@Column1, @Column2, @Column3, @Date, @ReceiptNo, @DeliveryPerson, @Report, @Flavours, @Return)";
connection.Open();
for (int j = 0; j < dataGridView1.Rows.Count ; j++)
{
var row = dataGridView1.Rows[j];
if (row.IsNewRow) continue;
command.Parameters.Clear();
command.Parameters.AddWithValue("@Column1", row.Cells[0].Value);
command.Parameters.AddWithValue("@Column2", row.Cells[1].Value);
command.Parameters.AddWithValue("@Column3", row.Cells[2].Value);
command.Parameters.AddWithValue("@Date", row.Cells[4].Value);
command.Parameters.AddWithValue("@ReceiptNo", label2.Text);
command.Parameters.AddWithValue("@DeliveryPerson", "---");
command.Parameters.AddWithValue("@Report", row.Cells[0].Value);
command.Parameters.AddWithValue("@Flavours", row.Cells[3].Value);
command.Parameters.AddWithValue("@Return", textBox66.Text);
command.ExecuteNonQuery();
} connection.Close();
MessageBox.Show("Inserted Sucessfully", "Database", MessageBoxButtons.OK, MessageBoxIcon.Information);