Im going to create a project with vb6 and ms access. I have to set password
to open the DB for security. In vb6, how can i connect the database in data environment through data link properties setting the provider,database and the database password?? If I can do this, are there any possible problems that will occur when I create and call commands in data environment?? Please help me. I urgently need this. Thank you..

Dani AI

Generated

Both and pointed in the right direction: Access database files that were encrypted with a database password can be opened from VB6 by supplying the right provider and the password to the connection. A couple of important distinctions that the thread hasn’t fully unpacked: Access “database password” (the simple Encrypt-with-password option) is different from Access user-level security (workgroup/MDW). Also, .mdb (Jet) and .accdb (ACE) use different OLE DB providers — pick the provider that matches the file you actually have.

Practical guidance for the Data Environment: don’t rely on the designer to stash the plain password inside the .dsr. Configure the DE connection so it does not auto-open at design time and supply the password at runtime before any DE Commands are executed. That prevents commands from failing due to a missing password and avoids leaving the password in your project files. Use the connection option that stops the password from being exposed after open (the “persist security info” behavior) if you want the run-time connection to forget the password — but be aware that then the password won’t be readable back from the connection object later.

Common gotchas and troubleshooting steps: wrong provider or file extension is a frequent cause of “unrecognized keyword” or driver errors; VB6 is 32-bit so you must install a compatible (32-bit) ACE driver to open .accdb on modern machines; file-permission locks or exclusive opens in Access will block connections; Jet-era encryption is weak — for real multiuser security consider SQL Server/Express or use ACCDB+ACE encryption. To isolate problems, test the provider/path/password with a .udl or a tiny test app, check file permissions, and ensure the ADODB libraries your app references match the provider you intend to use.

Recommended Answers

All 3 Replies

Set CN1 = New ADODB.Connection
CN1.CursorLocation = adUseClient

---------------------------------------------------------------------------------------
' This is a connect string for Access
CN1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="c:\data\icd02.mdb"


'password entry
CN1.Properties("jet OLEDB:Database Password") = "charlyX"

Thanks for the help.

Try this sample connection string.

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\mydb.mdb;" & _ 
           "Jet OLEDB:Database Password=MyDbPassword", _
           "myUsername", "myPassword"
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.