Avatar of sterankin
sterankin
 asked on

Inserting data from Gridview/Datatable into access database

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  
ASP.NET

Avatar of undefined
Last Comment
Reecio

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Reecio

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sterankin

ASKER
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...
Reecio

Reecio

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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
sterankin

ASKER
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?
Reecio

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.