Below is my code. How do I pass the password parameter to the database when trying to append a text file to a database?
Thank you.
Swi
Thank you.
Code:
Private Sub AddCSVDataToNewAccessTable(FilePath As String, MDBName As String, TxtFileName As String, TableName As String)
Dim sConTxt As String
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
sConTxt = "Driver={Microsoft Text Driver (*.txt; *.csv)}; "
sConTxt = sConTxt & "DEFAULTDIR=" & FilePath & "; "
sConTxt = sConTxt & "Persist Security Info=False"
cnn.Open sConTxt
rs.Open "SELECT * INTO [" & TableName & "] IN '" & FilePath & MDBName & _
"' FROM [" & TxtFileName & "]", cnn
End Sub
Private Sub Command1_Click()
AddCSVDataToNewAccessTable "C:\VBFiles\Barcode Reader\", "Mail.mdb", "20100809.txt", "Master"
MsgBox "Done!", vbInformation
End Sub
Swi