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.
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???
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.
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???