• Welcome to Valhalla Legends Archive.
 

Opening database in VB

Started by nkhan, April 20, 2004, 09:19 AM

Previous topic - Next topic

nkhan

Hello all

I have Microsoft Access database and I have set a database password on it. I am trying to open the database using the opendatabase method but I do not know how to pass the password.

I am using the following method:

Set dbs = OpenDatabase("c:\database.mdb")

Is there a way that I can supply the password, as the databse that I am trying to open is password protected.

Regards
Naeem Khan

Lycaon

Add a refence to the ActiveX Data Objects Library and use this:

Dim Conn As New ADODB.Connection

Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=C:\database.mdb;" & _
                        "Jet OLEDB:Database Password=YourPassHere"
Conn.Open