PC Review


Reply
Thread Tools Rate Thread

compact the user-level security

 
 
=?Utf-8?B?SmFja3k=?=
Guest
Posts: n/a
 
      27th Apr 2006
Hi,

I found the below code for compact the user level security.

When I call like this:
Call CompactAndRepairDB("C:\db1.mdb", "C:\compacttemp.mdb",
"C:\Secured.mdb", "Admin", "")

It give out the error message.

If I change to
Call CompactAndRepairDB("C:\db1.mdb", "C:\compacttemp.mdb",
"C:\Secured.mdb", "John", "johnpass")

Then the error message is:
Run-time error '-214727843 (80040e4d)'

Cannot start your application. The workgroup information file is missing or
opened exclusively by another user.

'************************************************* **************
' CompactAndRepairDB (FUNCTION)
'
' PARAMETERS:
' sSource - Path to source database
' sDestination - Path for destination database
' sSecurity - Path to Jet system database if there is
' one
' sUser - The username if user level security is
' turned on
' sPassword - The password if user level security is
' turned on
' lDestinationVersion - If the destination database should
' not be in the latest version of Jet
' then use this variable to specify
' the version required; 1 = Jet 1.0,
' 2 = Jet 1.1, 3 = Jet 2.x,
' 4 = Jet 3.x, 5 = Jet 4.x etc
'
' RETURN VALUE:
' Boolean - Success indicator
'
' DESCRIPTION:
' This function uses the Microsoft Jet and Replication Objects
' Library (part of ADO) to compact and repair a Microsoft Access
' database. A project reference is required to the Microsoft Jet
' and Replication Objects Library.
'
' You may want to add error handling to this procedure, or to
' the function that calls it as the compact and repair may fail,
' for instance, if exclusive access cannot be gained to the
' source database.
'************************************************* **************
Public Function CompactAndRepairDB(sSource As String, _
sDestination As String, _
Optional sSecurity As String, _
Optional sUser As String = "Admin", _
Optional sPassword As String, _
Optional lDestinationVersion As Long) As Boolean

Dim sCompactPart1 As String
Dim sCompactPart2 As String
Dim oJet As JRO.JetEngine

' Put together the provider string for the source database
sCompactPart1 = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source=" & sSource & _
";User Id=" & sUser & _
";Password=" & sPassword

' If the database has a user-level security file, add the
' details
If sSecurity <> "" Then
sCompactPart1 = sCompactPart1 & _
";Jet OLEDBystem database=" & sSecurity & ";"
End If

' Put together the provider string for the destination
' database
sCompactPart2 = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source=" & sDestination

' The destination database will end up in the latest version
' of jet, unless a specific version has been requested;
' 1 = Jet 1.0, 2 = Jet 1.1, 3 = Jet 2.x, 4 = Jet 3.x,
' 5 = Jet 4.x etc
If lDestinationVersion <> 0 Then
sCompactPart2 = sCompactPart2 & _
";Jet OLEDB:Engine Type=" & lDestinationVersion
End If

' Compact and repair the database
Set oJet = New JRO.JetEngine
oJet.CompactDatabase sCompactPart1, sCompactPart2
Set oJet = Nothing

CompactAndRepairDB = True
End Function


-------------------------------------------

I have a question.

How can I call the function using Admin without password?
How can I call the function using the username with password?

I want to know both of them.
Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: User Level Security Setup - Security Wizard Error Keith Wilby Microsoft Access Security 0 10th Jan 2007 12:39 PM
compact the user-level security =?Utf-8?B?SmFja3k=?= Microsoft Access Security 2 27th Apr 2006 06:29 PM
compact the user-level security =?Utf-8?B?SmFja3k=?= Microsoft Access VBA Modules 0 27th Apr 2006 07:21 AM
Security using Access user level security Microsoft Frontpage 1 23rd Feb 2005 07:56 PM
Need to bypass the admin-level password for user-level security TJ Microsoft Access Security 1 8th Sep 2003 12:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 AM.