Hi Douglas,
First- set the connection, and check for the provider(i.e, ""Microsoft.Jet.OLEDB.4.0"").
Then check for the password,
If password = 'yes'
""Provider="" & [Provider] & ""; Data Source="" & [Database] & ""; Jet OLEDB:Database Password="" & [Password] &"";""
If password = 'no'
""Provider="" & [Provider] & ""; Data Source="" & [Database] & "";""
Second- open the connection, with code stage as-
If moConnection Is Nothing Then
moConnection = New OLEDBConnection(ConnectionString)
moConnection.Open()
End If
Third- use the code to execute the query-
If moConnection Is Nothing Then
Dim strcon as String
Dim path as String
path = filePath
strcon = ""Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""+path+"";Extended Properties=Excel 12.0""
moConnection = New OLEDBConnection(strcon)
moConnection.Open()
End If
Fourth- close the connection, with code stage as-
moConnection.Close()
moConnection.Dispose()
moConnection = Nothing