Here i am simply giving the link for sending data to database.
void Save()
{
try
{
if (dataGridView1.Rows.Count > 1)
{
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
string col1 = dataGridView1.Rows[i].Cells[0].Value.ToString();
string col2 = dataGridView1.Rows[i].Cells[1].Value.ToString();
string col3 = dataGridView1.Rows[i].Cells[2].Value.ToString();
string col4 = dataGridView1.Rows[i].Cells[3].Value.ToString();
string col5 = dataGridView1.Rows[i].Cells[4].Value.ToString();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
string insert = "INSERT INTO InvoiceItems(SNo,Quantity,Rate,Description,Total) VALUES (@SNo,@Quantity,@Rate,@Description,@Total)";
con.Open();
SqlCommand cmd = new SqlCommand(insert, con);
cmd.Parameters.AddWithValue("@SNo", col1.ToString());
cmd.Parameters.AddWithValue("Description", col2.ToString());
cmd.Parameters.AddWithValue("@Quantity", col3.ToString());
cmd.Parameters.AddWithValue("@Rate", col4.ToString());
cmd.Parameters.AddWithValue("Total", col5.ToString());
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
I have not attached the progress bar in it.
Thanks Hope i helped you.