I have a set of records stored as a delimited text file and would like to append them to a table in a database. The idea is that the user will be prompted to open a database and the connection string will be constructed from the choice made. However I always get an error saying that the path is not valid Here's the code.
Private Sub cmdAppend_Click()
Dim connCSV As New ADODB.Connection
Dim rsTest As New ADODB.Recordset
Dim adcomm As New ADODB.Command
Dim path As String
MsgBox "Select database file"
dlgOpen.ShowOpen
path = dlgOpen.filename
MsgBox "path is " & path
If path = "" Then
MsgBox "You have not selected a database"
Exit Sub
Else
connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& path & ";Extended Properties='text;HDR=NO;FMT=Delimited'"
etc
etc
I'm afraid I'm a bit in the dark when it comes to connection strings etc. Is it possible to add records from a text file??
Private Sub cmdAppend_Click()
Dim connCSV As New ADODB.Connection
Dim rsTest As New ADODB.Recordset
Dim adcomm As New ADODB.Command
Dim path As String
MsgBox "Select database file"
dlgOpen.ShowOpen
path = dlgOpen.filename
MsgBox "path is " & path
If path = "" Then
MsgBox "You have not selected a database"
Exit Sub
Else
connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& path & ";Extended Properties='text;HDR=NO;FMT=Delimited'"
etc
etc
I'm afraid I'm a bit in the dark when it comes to connection strings etc. Is it possible to add records from a text file??