To remove all elements from the a BindingSource you need to simply call the
reportBindingSource.Clear();
and no need to loop over the single elements
If you want to remove all the rows from the database table then you need to prepare and execute a Sql Command appropriate for your database type.
Example for MySql - Needs the MySql NET Connector and the appropriate references to MySql.Data.dll
(Warning this removes the rows from the database without any exception)
using(MySqlConnection cnn = new MySqlConnection(....connectionstring..))
using(MySqlCommand cmd = new MySqlCommand("TRUNCATE TABLE yourTableName", cnn))
{
cnn.Open();
cmd.ExecuteNonQuery();
}
instead, if you have a condition then you need
(This removes only the rows from the database that satisfy the condition)
using(MySqlConnection cnn = new MySqlConnection(....connectionstring..))
using(MySqlCommand cmd = new MySqlCommand("DELETE FROM yourTableName WHERE ... your condition...", cnn))
{
cnn.Open();
cmd.ExecuteNonQuery();
}