insert large amount of records into access database

  • Thread starter Thread starter ireallyneedtoknow2007
  • Start date Start date
I

ireallyneedtoknow2007

hello i am using c# in visual studio 2005 and need to insert a large
number of records contained in a dataset into an access database. the
following is too slow. how can i update my DataAdapter with all the
rows(150000) at one time? thanks

foreach (DataRow row in ds.Tables[0].Rows)
{
DataRow dr = ds1.Tables["testtest"].NewRow();
dr = ds1.Tables["testtest"].NewRow();
dr["field1"] = row["field1"];
dr["field2"] = row["field2"];
ds.Tables[0].Rows.Add(dr);
ad.Update(ds1, "test");
}
 
With Access?

I don't think so.

At some point, you'll be running a 1 row by 1 row operation. Whether you do
it manually, or allow the dataadapter to do it for you.

You might write a Updateable Query, and call it, but it's still a "per row"
method.

If it were me, I wouldn't rely on the dataaadapter, ... at least right your
own code for the inserts.

.........

Switch to Sql Express 2005 and you'll have more options.


I have no idea what this is:
http://www.codeproject.com/dotnet/ELAB.asp

but maybe you can look into it.
 
I'm not really up to speed on Access, but try doing the ad.Update just one
time outstide the foreach. It should improve the speed.

foreach (DataRow row in ds.Tables[0].Rows)
{

}
ad.Update(ds1, "test");
 
I'm not really up to speed on Access, but try doing the ad.Update just one
time outstide the foreach. It should improve the speed.

foreach (DataRow row in ds.Tables[0].Rows)
{

}

ad.Update(ds1, "test");




hello i am using c# in visual studio 2005 and need to insert a large
number of records contained in a dataset into an access database. the
following is too slow. how can i update my DataAdapter with all the
rows(150000) at one time? thanks
foreach (DataRow row in ds.Tables[0].Rows)
{
DataRow dr = ds1.Tables["testtest"].NewRow();
dr = ds1.Tables["testtest"].NewRow();
dr["field1"] = row["field1"];
dr["field2"] = row["field2"];
ds.Tables[0].Rows.Add(dr);
ad.Update(ds1, "test");
}- Hide quoted text -

- Show quoted text -

Thank you, moving the update did the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top