A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert text file to access mdb



 
 
Thread Tools Display Modes
  #1  
Old February 6th, 2006, 04:56 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default Convert text file to access mdb

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.



  #2  
Old February 6th, 2006, 09:41 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default Convert text file to access mdb

I'd expect DAO to be faster than OLEDB, if it's available in your
environment. This is VBScript but shows what's involved. Note the
slightly different syntax for the text file data source.

Dim oJet 'As DAO.DBEngine
Dim oDB 'As DAO.Database
Dim strSQL 'As String

Const DB_NAME = "C:\Temp\Test 2003.mdb"
Const TBL_NAME = "My_Table"
Const DATA_SOURCE = "[Text;HDR=Yes;Database=C:\Temp\;].B1#txt"

Set oJet = CreateObject("DAO.DBEngine.36")
Set oDB = oJet.OpenDatabase(DB_NAME)

strSQL = "INSERT INTO " & TBL_NAME _
& " SELECT * FROM " & DATA_SOURCE & ";"

oDB.Execute strSQL

oDB.Close




On Mon, 6 Feb 2006 11:56:23 -0500, "jj" wrote:


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.




--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit/Add record in form from cmdButton doodle General Discussion 3 December 28th, 2005 03:06 AM
Help with design Ronnie Database Design 6 March 12th, 2005 02:53 PM
Access reports with a horizontal line after each record??? Bill via AccessMonster.com Setting Up & Running Reports 6 March 9th, 2005 04:51 PM
Unsafe Attachments Ron Installation & Setup 2 June 9th, 2004 01:55 AM
Productkey problem when installing office 2003 on network Stefan Schreurs Setup, Installing & Configuration 1 June 1st, 2004 11:16 PM


All times are GMT +1. The time now is 07:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.