Solved

Adding multiple rows to an mdb database using OleDb

Posted on 2009-04-14
10
307 Views
Last Modified: 2012-05-06
I have a simple mdb database with a simple table and i have a couple of thousand rows to insert into this table.

If i add them one by one its slow - is there any way to batch them together? In sql you just seperate them with carriage returns but that doesnt seem to work. Can someone give me an example?

0
Comment
Question by:tfsln
  • 5
  • 3
  • 2
10 Comments
 
LVL 13

Expert Comment

by:newyuppie
Comment Utility
Just to clarify... Where is the data that you want to insert to the database? A plain text file? Excel? Another MDB?

NY
0
 

Author Comment

by:tfsln
Comment Utility
It comes from a web service. But that shouldnt matter should it? The question is quite specific... I already have the data and i have built a number of insert statements like this;

Insert into testtable(test1,test2) Values('test1','test2')

What i want to know is the fastest way of committing those inserts to the database. Im guessing that running them in a batch would be quicker than running them one by one
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
Based on what you have said I would only expect there to be one insert query.  Why do you need more than one?
0
 

Author Comment

by:tfsln
Comment Utility
I gave an example of an insert query i am peforming. I have thousands of those inserts that i specified to perform all at once.
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
I have the same Q as NY then.

"Just to clarify... Where is the data that you want to insert to the database? A plain text file? Excel? Another MDB?"
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 13

Expert Comment

by:newyuppie
Comment Utility
0
 

Author Comment

by:tfsln
Comment Utility
I dont understand why it is so important to know where my data is coming from. It is not relevant. My question is specfic;

Given a list of transact-sql INSERT statements (the data i used to generate those statemets is not relevant to this question), how can i send that list to access for inserting - as opposed to running the insert one at a time?

In SQL server all you need to do is have a carriage return seperating each INSERT statement but that doesnt work for access and i suspect its a syntax thing.
0
 

Author Comment

by:tfsln
Comment Utility
newyupie: I cant make any sense of that link... It appears to me that all he is just doing it the long way by adding parameters using OleDbCommand when he could have just specified them in the Values clause and executed it straight away
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
Comment Utility
"how can i send that list to access for inserting - as opposed to running the insert one at a time?"

You can't.
Access/Jet SQL only processes one command at a time. You cannot combine commands into one sql script.
0
 

Author Comment

by:tfsln
Comment Utility
Ok cool, thats all i needed to know - cheers
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now