I want to import data from Excel to Access like this, it's working when my Access database has no password, but not working when it has a password. I copy this code from internet.
Where do I have to put the password of Access?
Dim Access As String = "C:\FWS\Database1.accdb"
Dim Excel As String = "C:\New folder\2h.xlsx"
' Dim connect As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Excel & ";Extended Properties=Excel 8.0;"
Dim connect As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Excel + ";Extended Properties=""Excel 12.0 Xml;HRD=NO"""
Using conn As New OleDbConnection(connect)
Using cmd As New OleDbCommand()
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [MS Access;Database=" & Access & "].[Password=frozbit].[tb_voucher2] SELECT * FROM [2hari$]"
If conn.State = ConnectionState.Open Then
conn.Close()
End If
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using