how do i access the access database from visual basic in connect

how do i access the access database from visual basic in connect

Post by c2F0eWFtdX » Tue, 06 Dec 2005 18:38:02


i have made a small package in visual basic with access as backend. i want to
use a database password but i am not able to access the mb file from vb.
please tell me the connectionstring to be used to be able to use the database
(mdb file) from vb.
 
 
 

how do i access the access database from visual basic in connect

Post by Brendan Re » Tue, 06 Dec 2005 20:35:19

You don't say whether you are using DAO or ADO, so here are examples of
opening a password-protected database using both ...

Public Sub TestConnect()

Dim db As DAO.Database
Dim cnn As ADODB.Connection

Set db = DBEngine.OpenDatabase("c:\usenet\db1.mdb", _
False, False, ";pwd=password")
MsgBox "Database opened OK!"
db.Close
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\usenet\db1.mdb;" & _
"Persist Security Info=False;" & _
"Jet OLEDB:Database Password=password"
MsgBox "Connection opened OK!"
cnn.Close

End Sub

--
Brendan Reynolds