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

S

satyamurti

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.
 
B

Brendan Reynolds

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top