Exporting 4.5 million records to text file from temp datatable
I have 4.5 million records in a temporary datatable, my goal is to export data to a text file in chunks of records until all records are written to textfile or processing
Can someone help me write the logic to export 750,000 records at a time until all records are gone. For every 750,000 records create its own text file. Below is the logic I using below in code, can you guys help me modify logic below
DataTable dataTable = new DataTable ();
dataTable.Columns.Add(new DataColumn("UNIT", typeof(string)));
dataTable.Columns.Add(new DataColumn("SERIAL", typeof(string)));
dataTable.Columns.Add(new DataColumn("PART", typeof(string)));
SqlDataReader dr = cm.ExecuteReader();
while(dr.Read())
{
nextRow = dataTable.NewRow();
nextRow["UNIT"] = row.UNIT;
nextRow["SERIAL"] = row.SERIAL;
nextRow["PART"] = row.PART;
dataTable.Rows.Add(nextRow);
}