myester
asked on
How to import text file into MS Access database
I'm trying to import a comma delimited text file into a MS Access database with vb.net. The text file I want to import is named ACD5.txt. The database name is Support_Stats.mdb with one table named Calls. I'm trying the code below, but I'm getting the An unhandled exception of type 'System.Data.OleDb.OleDbEx ception' occurred in system.data.dll error on the cmd.ExecuteNonQuery line. Please see the attached code.
Dim connect As String
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=U:\Manager\Support Team Measurement\Stats_Database\Support_Stats.mdb"
Dim conn As New OleDbConnection(connect)
Dim path As String = "U:\Manager\Support Team Measurement\Stats_Database\Support_Stats.mdb"
Dim query As String = "INSERT INTO Calls (Week Starting, Inbound ACD Calls, Avg Inbound ACD Time) SELECT Week Starting, Inbound ACD Calls, Avg Inbound ACD Time FROM [Text;DATABASE=" & path & ";].[ACD5.txt]"
Dim cmd As OleDbCommand = New OleDbCommand(query, conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER