|
Subject:
|
Connecting to workgroup protected database
|
|
Posted By:
|
Scripts82
|
Post Date:
|
2/15/2006 12:23:05 AM
|
Hi I am trying to connect from an Access application to another Access mdb database file. I have got the workgroup set up, with the user "myself" granted full access to this protected database. However, I keep getting the following error:
"Cannot start your application. The workgroup information file is missing or opened exlusively by another user."
Can someone help me with this? I have the error persisted no matter whether I am currently logged into the workgroup or the default workgroup.
My code is as follows:
/////////////////////////////////////////////////////////////////// Dim conRemote As New adodb.Connection Dim strCon as string
strCon = "Provider = Microsoft.Jet.OLEDB.4.0; " & _ "Data Source = RemoteData.mdb; User Id =myself; Password = password;"
conRemote.Open strCon ///////////////////////////////////////////////////////////////////
Scripts82
|
|
Reply By:
|
Bob Bedell
|
Reply Date:
|
2/15/2006 6:19:17 AM
|
Hello,
You need to tell your connection object where the workgroup information file is located as well:
Sub ConnectToSecuredMDB()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
On Error GoTo Err_Handler
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = "C:\SecuredDatabase.mdb"
.Properties("Jet OLEDB:System Database") = "C:\WorkgroupInformationFile.mdw"
.Properties("Mode") = adModeShareDenyNone
.Properties("User ID") = "John Doe"
.Properties("Password") = "John"
End With
cnn.Open
strSQL = "SELECT * FROM tblRecords"
Set rst = New ADODB.Recordset
rst.Open strSQL, cnn, adOpenForwardOnly, adLockReadOnly, adCmdText
Debug.Print rst.GetString(adClipString, , ";")
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
Err_Handler:
If Not rst Is Nothing Then
If rst.State = adStateOpen Then rst.Close
End If
Set rst = Nothing
If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then cnn.Close
End If
Set cnn = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
HTH,
Bob
|
|
Reply By:
|
Scripts82
|
Reply Date:
|
2/15/2006 9:28:48 AM
|
Thanks! Got that after some searching on the net too...
Scripts82
|