Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2004

Tip: Looking for answers? Try searching our database.

Opening up a Password protected file using VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy Morgan - 25 Nov 2004 19:23 GMT
Please can you help?

I am writing some code that will show what users are using a shared database
and in the code I have to put what file I am looking at so I have put the
path in but the file is password protected and when i run the code it is
telling me that the password is incorrect please can you tell me how I can
enter the password into the code.

Please see example of what I have go so far:-
Sub showUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"

cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-dbdf-00c04fb92675}")

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

The password is for the Staff Info Database.mdb
Juan M Afan de Ribera - 25 Nov 2004 20:57 GMT
Hi,

try this way:

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

   Set cn = New ADODB.Connection
   With cn
       .Provider = "Microsoft.Jet.OLEDB.4.0"
       .ConnectionString = "Data Source=c:\MyDatabase.mdb"
       .Properties("Jet OLEDB:Database Password") = "here_the_db_password"

       .Open
   End With

   '... and so

Saludos,
Juan M Afan de Ribera
[MVP Access]
http://www.mvp-access.com/juanmafan

> Please can you help?
>
[quoted text clipped - 37 lines]
>
> The password is for the Staff Info Database.mdb
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.