i want to save multiple datagridview row in database
private void cmdSave_Click(object sender, EventArgs e)
{
con.Open ();
SqlCommand comm = new SqlCommand();
comm.Connection = con;
string col1 = dgvChallan[0, dgvChallan.CurrentCell.RowIndex].Value.ToString();
string col2 = dgvChallan[1, dgvChallan.CurrentCell.RowIndex].Value.ToString();
string col3 = dgvChallan[2, dgvChallan.CurrentCell.RowIndex].Value.ToString();
string sqlQury = "INSERT INTO purchaseform(ItemName,Quantity,Unit)VALUES('"+ col1 +"','"+ col2 +"','"+ col3 +"')";
comm.CommandText = sqlQury;
comm.ExecuteNonQuery();
con.Close();
}
}
this code is saving only one row which is last in datagrid view.how we can save multiple rows