We help IT Professionals succeed at work.

Inserting data from Gridview/Datatable into access database

sterankin asked
Last Modified: 2008-07-23
Currently - the user creates and excel spreadsheet on their desktop with some data, then uses the ASP.NET web app to upload the excel spreadsheet.  The data is read in from the spreadsheet and put into a DataTable which is then bound to a gridview for the user to see and verify.

I then want to be able to insert the data from the datatable into an Access DB (the columns should match).

How do I do this?  Is there a simple way to Insert the datatable or the rows from the datatable into the access database?
Access table: TestTable
Columns:  Column1, Column2, Column3, Column4 etc  
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


I will look into that thanks - I read there may be a way to do it with a DataAdapter, or a bulk update?  But I have not found any details on this...

However, that is for data in a gridview, but if you load the data in to a gridview that you have made invisible you might be able to pull off the same effect?

Otherwise looping for each row is the only other way I can think of, in fact, the control basically does that, as on rowdatabound is activated when a row is bound to the control.


Reecio - I had a look at that link to msdn, but I am not sure how this would work with the excel file.

Basically I am loading data from an excel file to the gridview.  I then want to insert all the rows into an access database.

Is the only way to do this by using a loop?

I know there is a way to insert in bulk but via SQL statements, so i'm not sure how to best implement it with this exercise. I have found a bulk insert statement that uses stored procedures (http://support.microsoft.com/default.aspx?scid=kb;EN-US;316244) but dont think there is an easy way to do it just in code unless via a loop.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.