DB Connection

D

Dillan

I have a custom form that connects to an access 97 database. This works
fine until I password protect the database. When trying to connect to a
password protected database I get the err “Cannot start your
application. The workgroup information file is missing or opened
exclusively by another user.”
My code is as follows (with thanks to Jumpstart Outlooks Programming by
Sue Mosher)

Function Item_Open()
Dim sSelect
‘On Error Resume Next
If Item.SenderName = “” Then
sSelect = “V:\ServiceSelector\ServiceSelector.mdb”
Set m_adoSerSel = OpenAccessDB(sSelect, “admin”, “irate”)
End If
End Function

Function OpenAccessDB(sDBPath, UID, PWD)

Dim objADOConn
Dim sConn
‘On error Resume next

sConn = “Provider=Microsoft.Jet.OLEDB.4.0; “ &_
“Data Source=” & sDBPath & “; “ &_
“User ID=” & UID & “; “ & _
“Password=” & PWD & “; “

Set objADOConn = CreateObject(“ADODB.Connection”)
ObjADOConn.Open sConn

If (err = 0) And (objADOConn.State = adStateopen) Then
Set OpenAccessDb = objADOConn
Else
Set OpenAccessDB = Nothing
End If

Set objADOConn = Nothing

End Function


Please Note I’ve commented out the error handlers to help debugging (but
it didn’t help that much)




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
C

carl lorentson

HI Dillan,

If you are opening a Password protected .mdb, you'll need to set the
database password as follows:

"Jet OLEDB: Database Password=password;"
(Source: Access Developers Handbook, Ken Getz)

If you are opening a Jet-secured database with a workgroup you'll need
something like this:

Dim MyConn As New ADODB.Connection
Dim strConn As String

strConn = "Data Source=C:\...\JetSecurity.MDB;" & _
"Jet OLEDB:System database=C:\...\System.MDW"
MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"
MyConn.Open ConnectionString:=strConn, _
UserID:="Admin", Password:="MyPwd"

See Microsoft Knowledge base article #191754 for other ways to do this.

Hope this helps,
Carl Lorentson
Reniassance Information System, Inc.
 
D

Dillan

Carl,
Thanks for your reply. Yes I'm using a password protected .mdb. Can you
explaine where the line you suggested "Jet OLEDB: Database
Password=password;"
fits into my connection string?

sConn = "Provider=Microsoft.Jet.OLEDB.4.0; " &_
"Data Source=" & sDBPath & "; " &_
"User ID=" & UID & "; " & _
"Password=" & PWD & "; "
Thanks
Dillan


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
C

carl lorentson

It can go right at the end since it is a named parameter:

sConn = "Provider=Microsoft.Jet.OLEDB.4.0; " &_
"Data Source=" & sDBPath & "; " &_
"User ID=" & UID & "; " & _
"Password=" & PWD & "; " & _
"Jet OLEDB: Database Password=password;"

Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top