convert comma delimited text to access mdb

J

jj

I have this comma delimited text file. I want to convert it in one sweep to
an access DB (mdb) format. I used the following code but it takes forever to
convert. Is there a faster way?

string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strAppPath + "\\mydb.mdb";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd = new OleDbCommand("INSERT INTO mytable Select * from [Text;DATABASE="
+ strAppPath + ";].[mytextdata.txt]",conn );
cmd.ExecuteNonQuery();
conn.Close();


Any help is greatly appreicated and thank you in advance.
 
G

Griff

Is this a one-off task or something that you would need to do every time a
program runs?

I don't know much about Access, but with SQL Server it's possible to do a
bulk insert which can be frighteningly fast.
 
J

jj

The conversion is done at the end of my scan application. For a one
scan(that takes long hours) I will do the conversion at the end inorder to
create reports.

any help please
 
J

jj

can you send me the one for SQl server and then I can try to modfiy for
Access.

Thanks
 
P

Paul Clement

¤ I have this comma delimited text file. I want to convert it in one sweep to
¤ an access DB (mdb) format. I used the following code but it takes forever to
¤ convert. Is there a faster way?
¤
¤ string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
¤ strAppPath + "\\mydb.mdb";
¤ OleDbConnection conn = new OleDbConnection(strConn);
¤ conn.Open();
¤ OleDbCommand cmd = new OleDbCommand();
¤ cmd = new OleDbCommand("INSERT INTO mytable Select * from [Text;DATABASE="
¤ + strAppPath + ";].[mytextdata.txt]",conn );
¤ cmd.ExecuteNonQuery();
¤ conn.Close();

How many lines are there in your text file?

Just an FYI, there is no bulk insert capability in Jet.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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

Top