I have a datatable table which have multiple records. I want to Insert this datatable to ms-access table without using loop.
I want to insert multiple rows/records into ms-access database as whole. I don't want to insert records one by one.
using (var conn = new OleDbConnection(DatabaseObjects.ConnectionString))
{
      var adap = new OleDbDataAdapter();
      adap.SelectCommand = new OleDbCommand ("select RollNo, SName, FName, DOB, [Section] from students", conn);
      var cb = new OleDbCommandBuilder(adap);
      cb.GetInsertCommand();
      cb.GetDeleteCommand();
      cb.GetUpdateCommand();
      conn.Open();
      adap.Update(table);   
 }
Loading of data from excel sheet to datatable. code is below,
using (OleDbConnection connExcel = new OleDbConnection(DatabaseObjects.ConnectionStringExcel))
        {
            string queryExcel = "select * from [" + sheetName + "$]";
            using (OleDbCommand commandExcel = new OleDbCommand(queryExcel, connExcel))
            {
                connExcel.Open();
                OleDbDataAdapter adapter = new OleDbDataAdapter();
                adapter.SelectCommand = commandExcel;
                adapter.Fill(dtSheetData);
            }
        }