Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Database

Status
Not open for further replies.

Panucci

Programmer
Jan 11, 2001
3
0
0
BR
I have an Microsoft Access Database with a password that I know it.
My trouble is how can I open this database in Visual Basic.
I need a sintaxe of opendatabase command.
Thanks
 
Here is an example opening a connection using ADO.

Public Sub OpenDB()
Dim strDB As String
strDB = "c:\db\ww.mdb"

'open the connection
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.CursorLocation = adUseClient
cn.Open strDB
End Sub
 
Where I will insert the password of Microsoft Access Database.
I didn't undertand your answer.
 
DAO :

Dim password As String
password = "edderic"
Dim strPath As String
Dim db As DAO.Database

strPath = IIf(Right$(App.Path, 1) <> &quot;\&quot;, App.Path &amp; &quot;\&quot;, App.Path)
strAccessFile = &quot;Scriptie01.mdb&quot;
Set db = appAccess.DBEngine.OpenDatabase(strPath &amp; strAccessFile, False, False, &quot;MS Access;pwd=&quot; &amp; password) Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
I was searching the forum for an answer to this problem, and erreric's post worked for me, but only after I removed appAccess. from:

Set db = appAccess.DBEngine.OpenDatabase(strPath & strAccessFile, False, False, &quot;MS Access;pwd=&quot; & password)

Randy
 
Public Cnn As New ADODB.Connection
sDataBaseName =&quot;c:\DBName.mdb&quot;

Cnn.ConnectionString = &quot;ODBC;DBQ=&quot; & sDataBaseName _ & &quot;;UID=;PWD=;Driver={Microsoft Access Driver (*.mdb)}&quot;

enter the user id in UID and password in PWD
'Referance: ADO 2.5 Library

Hope this helps
Murali Bala
 
or

If you are using the Microsoft Jet Provider:


sDataBaseName = &quot;YourDatabase.mdb&quot;
sDBPassword = &quot;YourDBPassword&quot;

Dim Cnn As New ADODB.Connection

With Cnn
.Provider = &quot;Microsoft.Jet.OLEDB.4.0&quot;
.Properties(&quot;Jet OLEDB:Database Password&quot;) = sDBPassword
.Mode = adModeReadWrite
.Open sDataBaseName
End With

Regards,

Codefish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top