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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening Access 2.0 database with password

Status
Not open for further replies.

kenguru

Programmer
May 14, 2004
173
0
0
RO
Hi everyone!

Could anyone tell how it is possible to open a username&password protected Access 2.0 database from VB?
Or where should I look up for it?

Many thank's
Kenguru
 
Ken,
Not sure what data access method you are using but with ADO it should work if you include in your connection string ";user id = x;password = y;data source =" etc where x is your username and y is your password.
I think with ODBC you select 'advanced' when configuring your datasource and enter the user name and password where prompted.
HTH
Bob
 
I tried the following code:

Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Dim SecuredDB As String
Dim slUserName As String
Dim slPassword As String
Dim db As Database
Dim rs As Recordset

'Set the location of the system database
DBEngine.SystemDB = _
"C:\Access\system.mda"

'Create a new workspace object
slUserName = Text1.Text
slPassword = Text2.Text
Set MyWorkspace = DBEngine.CreateWorkspace("New", _
slUserName, _
slPassword)

'Open the database
SecuredDB = _
"D:\ABC.mdb"
'Set db = DBEngine.Workspaces("New").OpenDatabase(SecuredDB)
' Set db = DBEngine.Workspaces.Append MyWorkspace


Set rs = db.OpenRecordset("Names", dbOpenDynaset)
rs.MoveFirst
Label3.Caption = _
"The first record is " & rs.Fields
"LastName").Value

'Close the recordset and the database
rs.Close
db.Close
End Sub

But at the line
'Set db = DBEngine.Workspaces("New").OpenDatabase(SecuredDB)
it gave me the following error: Error: Run-time Error '3265'Item not found in this collection.

And the following line:
' Set db = DBEngine.Workspaces.Append MyWorkspace
isn't working ...:(

Please do you have any idea?
Many thank's
Kenguru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top