Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to transfer Excel data sheet to an Access Table

How to transfer Excel data sheet to an Access Table

Scheduled Pinned Locked Moved C#
csharphelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rameshika
    wrote on last edited by
    #1

    Hi, I am writing a small program, where I need to transfer Excel Data into Access tables using C#.Net.If anyone has attempted this please be kind enough to help me on this. Rameshi

    P 1 Reply Last reply
    0
    • R rameshika

      Hi, I am writing a small program, where I need to transfer Excel Data into Access tables using C#.Net.If anyone has attempted this please be kind enough to help me on this. Rameshi

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Use the JET OLE DB Provider to connect to your spreadsheet. Loop through the data in the spreadsheet and run an INSERT query on your Access database for each row of data.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      M 1 Reply Last reply
      0
      • P pmarfleet

        Use the JET OLE DB Provider to connect to your spreadsheet. Loop through the data in the spreadsheet and run an INSERT query on your Access database for each row of data.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        M Offline
        M Offline
        MickCurley
        wrote on last edited by
        #3

        You could also fill a datatable from from the excel spreadsheet (ExcelDT) and also fill another datatable from the Access Table (AccessDT). Then just use a foreach loop on the excel datatable:

             foreach (DataRow row in ExcelDT.Rows)
             {          
                DataRow newrow = AccessDT.NewRow();
        
                newrow.ItemArray = row.ItemArray;           
                
                AccessDT.Rows.Add(newrow);
        
             }
        

        Finally call update on the AccessDT and Bingo your done :) Hope this helps.

        A craft is an enemy if not well learned.

        P 1 Reply Last reply
        0
        • M MickCurley

          You could also fill a datatable from from the excel spreadsheet (ExcelDT) and also fill another datatable from the Access Table (AccessDT). Then just use a foreach loop on the excel datatable:

               foreach (DataRow row in ExcelDT.Rows)
               {          
                  DataRow newrow = AccessDT.NewRow();
          
                  newrow.ItemArray = row.ItemArray;           
                  
                  AccessDT.Rows.Add(newrow);
          
               }
          

          Finally call update on the AccessDT and Bingo your done :) Hope this helps.

          A craft is an enemy if not well learned.

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          This method adds unnecessary overhead to the process. It is more efficient to use a DataReader to access the Excel data and run direct INSERT statements against the Access database.

          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups