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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |