I found a solution during my googling. But it is not working in my case, can any body please check this code. this what I found: public partial class Form1 : Form { public static string ConnectionString = "" //your connection string here DataSet DS = new DataSet(); double TotalRows =0; double RowIndex = 1; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { OleDbConnection DBConn = new OleDbConnection(ConnectionString); OleDbDataAdapter DBAdapter = new OleDbDataAdapter(); DBAdapter.SelectCommand = new OleDbCommand("SELECT Count(*) from tblPersons", DBConn); DBConn.Open(); TotalRows = (int)DBAdapter.SelectCommand.ExecuteScalar(); //retrieve the nr. of rows in the DB Table DBConn.Close(); DBAdapter.SelectCommand.CommandText = "SELECT * from tblPersons"; DS.Tables.Add(new DataTable("Customers")); // Add event handler to the row changing event in the dataset DS.Tables["Customers"].RowChanging += new DataRowChangeEventHandler(Form1_RowChanging); DBAdapter.Fill(DS, "Customers"); dataGridView1.DataSource = DS.Tables[0]; } void Form1_RowChanging(object sender, DataRowChangeEventArgs e) { if (e.Action.ToString() == "Add") //check if the action is 'Add' (not 'Commit') { Thread.Sleep(500); progressBar1.Value = (int)Math.Round((double)(RowIndex / TotalRows) * 100); //update the progressbar progressBar1.Refresh(); RowIndex++; //count rows } } } }
Kutty