Hi Everyone
I m trying to open password protected Database for Data Report applying the following Code in Command Button1.

Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset
Set CN = New ADODB.Connection
Set RS = New ADODB.Recordset
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source =" & App.Path & ".\MyDataBase.mdb"

CN.Open
Set RS = CN.Execute("Select * From Tabel1 Where Name ='" & txtName.Text & "'")
Set DataReprot1.DataSource = RS

DataReprot1.Show

But its showing error please, anyone tell me how can I set the connection for password protected Database.

Dani AI

Generated

Acknowledgement: is trying to open a password‑protected Access file for a VB6 DataReport; was correct that the connection must carry the database credentials. Two different Access protections are commonly confused and require different handling: a simple database (file) password, or user‑level security that uses a system MDW and a login. The report/display side (DataReport) also imposes constraints: the recordset must be accessible to the report (either keep the connection open while showing the report, or hand the report a client‑side/disconnected recordset).

Practical checklist (most common pitfalls)

  • Determine protection type: a single password prompt = database password; a login dialog = user‑level security (system.mdw).
  • Use the appropriate authentication form: database password goes into the connection; user‑level requires the system database path and user credentials.
  • If the file is .accdb (Access 2007+), use the ACE provider instead of Jet.
  • Build the file path robustly (handle App.Path trailing backslash).
  • Ensure the VB6 project references Microsoft ADO and that the Jet/ACE provider is present on the machine.
  • For DataReport, prefer a client‑side, static recordset so the report can enumerate rows after the connection is closed.

Example workflow (ADO, with placeholders — do not reuse any code already posted in thread):

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
cn.Open myConnString   ' build this to include the necessary DB auth

Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM Table1 WHERE [Name] = '" & txtName.Text & "'", cn, adOpenStatic, adLockReadOnly
Set rs.ActiveConnection = Nothing   ' disconnect so report can use it
cn.Close

Set DataReport1.DataSource = rs
DataReport1.Show

Important caution: suggestions to run “password breakers” (as mentioned by ) can be illegal or corrupt the file. If the password is legitimately lost, use backups or contact the database owner/administrator; do not attempt unauthorized cracking. Capturing the exact error number/message when CN.Open fails usually reveals whether the problem is a bad path, missing provider, or authentication issue.

Recommended Answers

All 6 Replies

Hi,

open password protected database like this :

CN.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source="& App.Path & _
"\MyDataBase.mdb" & ";" & _
"Jet OLEDB:Database Password=MyPWd" 

    CN.Open

Regards
Veena

hi veena
our company has a passwor protected database.can we open tthat database.
regards
suneel


Hi,

open password protected database like this :

CN.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source="& App.Path & _
"\MyDataBase.mdb" & ";" & _
"Jet OLEDB:Database Password=MyPWd" 

    CN.Open

Regards
Veena

Hi,

If it is in Access, and if u know the Password then u can open it with the above code..

Regards
Veena

hi veeeeeeee
if password is known anyone can access the databae. without password is it possible
regards
suneel


Hi,

If it is in Access, and if u know the Password then u can open it with the above code..

Regards
Veena

hi veena
and wt if i ddont know the passwod
regaards
suneel

Hi,

Try for some Password Breakers...

I gave the code In view of a "Developer"

Not As A "Hacker"..... :)--Vee

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.