Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing text file into access

Status
Not open for further replies.

shorty545

IS-IT--Management
Apr 5, 2004
82
US
Here is what I am trying to do. Hopefully someone with more knowledge than me can help.

I want to write a code that will open a text file on a local pc, and import that text file directly into an Access database.

There will be several files to import and therefore several tables in Access.

I am getting stuck & confused when trying to configure the oledbadapter. Should I configure the adapter in the design mode or in the code mode?

Any help or guidance would be greatly appreciated.

Thanks...

 
When I run what I think should work i get the following error.

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

Here is my Code:

Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\db1.mdb")

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [tbl1] SELECT * FROM [Text;DATABASE=c:\CSV.txt]", AccessConn)

AccessCommand.ExecuteNonQuery()
AccessConn.Close()

The program bombs out on the AccessCommand.ExecuteNonQuery() function everytime.

Any Advice???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top