Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding multiple rows to an mdb database using OleDb

Posted on 2009-04-14
10
Medium Priority
?
331 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
ID: 24143422
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
ID: 24143475
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
ID: 24143551
Based on what you have said I would only expect there to be one insert query.  Why do you need more than one?
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

Author Comment

by:tfsln
ID: 24143557
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
ID: 24143595
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
 
LVL 13

Expert Comment

by:newyuppie
ID: 24143604
0
 

Author Comment

by:tfsln
ID: 24143647
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
ID: 24143655
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 2000 total points
ID: 24143678
"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
ID: 24143681
Ok cool, thats all i needed to know - cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

772 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