Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: nkhan on April 20, 2004, 09:19 AM

Title: Opening database in VB
Post by: nkhan on April 20, 2004, 09:19 AM
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
Title: Re:Opening database in VB
Post by: Lycaon on June 08, 2004, 05:11 PM
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