CompactRepair on a secured Access db

J

Jonathan

Hello all,
Is there a way to run the CompactRepair method on a user secured database?
This code works fine on an unsecured db but not on a secured one.

VB6.0 code...

Dim strSource As String
Dim strTarget As String
Dim blnLogfile As Boolean
Dim blnRet As Boolean
Dim app As New Access.Application

strSource = "C:\database\Secured_db.mdb"
strTarget = "C:\database\Repaired_db.mdb"
blnRet = app.CompactRepair(strSource, strTarget, blnLogfile)

Jonathan
 
R

Ralph

Jonathan said:
Hello all,
Is there a way to run the CompactRepair method on a user secured database?
This code works fine on an unsecured db but not on a secured one.

VB6.0 code...

Dim strSource As String
Dim strTarget As String
Dim blnLogfile As Boolean
Dim blnRet As Boolean
Dim app As New Access.Application

strSource = "C:\database\Secured_db.mdb"
strTarget = "C:\database\Repaired_db.mdb"
blnRet = app.CompactRepair(strSource, strTarget, blnLogfile)

Jonathan

Describe "secured". Database password, User-Level Security, on a disk in his
rucksack, ... ?

-ralph
 
J

Jonathan

User-level security... sorry for the ommision

Ralph said:
Describe "secured". Database password, User-Level Security, on a disk in his
rucksack, ... ?

-ralph
 
J

Joan Wild

Do you get an error message when you attempt this?

Do users have Open Exclusive permission on the Database Object?
 
J

Jonathan

Hi Joan,
I'm trying the solution referenced by Paul, above. Here is the code:
================================================
Private Sub main()
Dim jro As jro.JetEngine
Dim strSource As String
Dim strTarget As String
Dim strProvider As String
Dim strWGrp As String

strProvider = "Microsoft.Jet.OLEDB.4.0;"
strWGrp = "Jet OLEDB:System database=C:\DB\\DB.mdw;"
strSource = "Data Source=C:\DB\db1.mdb;User ID=DBAdmin"
strTarget = "Data Source=C:\DB\repaired.mdb;User ID=DBAdmin"

Set jro = New jro.JetEngine
jro.CompactDatabase strProvider & strWGrp & strSource, strProvider & strWGrp
& strTarget
End
End Sub
=====================================================
I get this error on the CompactDatabase
"Cannot start your application. The workgroup information file is missing or
opened exclusively by another user"


See anything in this?

Jonathan
 
J

John Mishefske

Jonathan said:
Hi Joan,
I'm trying the solution referenced by Paul, above. Here is the code:
================================================
Private Sub main()
Dim jro As jro.JetEngine
Dim strSource As String
Dim strTarget As String
Dim strProvider As String
Dim strWGrp As String

strProvider = "Microsoft.Jet.OLEDB.4.0;"
strWGrp = "Jet OLEDB:System database=C:\DB\\DB.mdw;"
strSource = "Data Source=C:\DB\db1.mdb;User ID=DBAdmin"
strTarget = "Data Source=C:\DB\repaired.mdb;User ID=DBAdmin"

Set jro = New jro.JetEngine
jro.CompactDatabase strProvider & strWGrp & strSource, strProvider & strWGrp
& strTarget
End
End Sub
=====================================================
I get this error on the CompactDatabase
"Cannot start your application. The workgroup information file is missing or
opened exclusively by another user"

If any other user or any object in the current database has a connection to the .mdb file
in question then you won't be able to get exclusive access to the .mdb file. That is a
requirement before compacting. You certainly wouldn't want to be compacting if another
user is designing a form or entering data.

Given that, you can never compact from within the currently open database file without
resorting to either the Compact On Close option or using SendKeys to select the menu
option to do this (I believe, unless perhaps you opened the .mdb file exclusively initially).
 
P

Paul Clement

¤ Hi Joan,
¤ I'm trying the solution referenced by Paul, above. Here is the code:
¤ ================================================
¤ Private Sub main()
¤ Dim jro As jro.JetEngine
¤ Dim strSource As String
¤ Dim strTarget As String
¤ Dim strProvider As String
¤ Dim strWGrp As String
¤
¤ strProvider = "Microsoft.Jet.OLEDB.4.0;"
¤ strWGrp = "Jet OLEDB:System database=C:\DB\\DB.mdw;"
¤ strSource = "Data Source=C:\DB\db1.mdb;User ID=DBAdmin"
¤ strTarget = "Data Source=C:\DB\repaired.mdb;User ID=DBAdmin"
¤
¤ Set jro = New jro.JetEngine
¤ jro.CompactDatabase strProvider & strWGrp & strSource, strProvider & strWGrp
¤ & strTarget
¤ End
¤ End Sub
¤ =====================================================
¤ I get this error on the CompactDatabase
¤ "Cannot start your application. The workgroup information file is missing or
¤ opened exclusively by another user"
¤

I don't believe that the security information would be specified for the destination database. See
if the following example works for you:

http://www.freevbcode.com/ShowCode.asp?ID=2879


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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