(though it uses SQLite, you can also try the same for anyother db)
[Each time I was retrieving a fixed amount of record from SQL server and using this code]
using (SQLiteTransaction dbTransaction = dbConnection.BeginTransaction()) { using (System.Data.SQLite.SQLiteDataAdapter dbAdapter = new SQLiteDataAdapter()) { using (SQLiteCommand dbCommand = dbConnection.CreateCommand()) { dbCommand.Transaction = dbTransaction; dbCommand.CommandText = "Select * from " + sqliteTableName + " Where 1 = 2"; dbAdapter.SelectCommand = dbCommand; using (SQLiteCommandBuilder cb = new SQLiteCommandBuilder()) { //set the data adapter property cb.DataAdapter = dbAdapter; using (dbAdapter.InsertCommand = (SQLiteCommand)((ICloneable)cb.GetInsertCommand()).Clone()) { // unregister the cb.DataAdapter = null; foreach (DataRow dbRow in dbTable.Rows) { dbRow.SetAdded(); } dbAdapter.Update(dbTable); dbTransaction.Commit(); } } } } if (dbConnection.State != ConnectionState.Closed) { dbConnection.Close(); } }