0
Main()
{
     WinOpTableAdapters.attendanceTableAdapter tx;
     tx = new WinOpTableAdapters.attendanceTableAdapter();

     Thread th = new Thread(new ThreadStart(Insrt));  //thread
     th.Start();
}

void Insrt()
{
    WinOpTableAdapters.attendanceTableAdapter tx;
    tx = new WinOpTableAdapters.attendanceTableAdapter();

    for (int j = 0; j <= 100000; j++)
    {
        tx.InsertQueryAttend("Admin" + j);
    }
}

I want to insert 1 million items of data into a database in more efficient way, the code shown takes 5 mins to insert 5000 rows into database

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
lokesh ms
  • 1
  • 2

1 Answers1

0

SqlBulkCopy is the best method to copy large amounts of data into a database. Some examples for SqlBulkCopy

If you are using Entity Framework, https://stackoverflow.com/a/9162325/311255

Community
  • 1
  • 1
SelvaS
  • 1,771
  • 1
  • 22
  • 28