running a compact script, security issue

J

JRough

I have a perfect vbscript to compact a database but I get password
errors. I try it two ways, with only the database password and with
a developer password/login. Neither works. I don't know if I need to
give permissions to any of the security objects in security with
either of these passwords?


First I try the script using the db pw with the db pw set.
It brings up the normal user level dialogue and I enter the pw/login
for the developer
and it says error " not a valid account and password. Even with the
db pw set it still asks for a user level pw.

offending line of vbscript with database password:
objAccess.DBEngine.CompactDatabase strPathToMDB, strTempDB,
";pwd=Kiyote#3"

So I unset the password and change the script line to run without
that option(see line below)
It brings up a user level pw dialogue and I get the same error
message "not a valid account and password". I
also try this with another admin password/login.
objAccess.DBEngine.CompactDatabase strPathToMDB, strTempDB

Do I have to give the priviledge to run the
vbscript to the database password somehow?

There are only 2 user level passwords known to me. The user does not
remember anything else.
One is admin and the other is developer. The developer password has
the ability to change all objects except the database object. The
admin user has access to all objects except in database object "modify
design".

I should be able to use the
database password to run the script so why does it bring up the user
level password dialogue?

By the way it says source DAO.engine. Does that mean I need to
install some library? i don't really think so I think it is a
security issue but I don't know how to solve it. thnx,
 
J

JRough

 I have a perfect vbscript to compact a database but I get password
errors.   I try it two ways, with only the database password and with
a developer password/login. Neither works.  I don't know if I need to
give permissions to any of the security objects in security with
either of these passwords?

First I try the script using the db pw with the db pw set.
It brings up the normal user level dialogue and I enter the  pw/login
for the developer
and it says error " not a valid account and password.  Even with the
db pw set it still asks for a user level pw.

offending line of vbscript with database password:
objAccess.DBEngine.CompactDatabase strPathToMDB, strTempDB,
";pwd=Kiyote#3"

So I  unset the password and change the script line to run without
that option(see line below)
It brings up a user level pw dialogue  and I get the same error
message "not a valid account and password".  I
also try this with another admin password/login.
objAccess.DBEngine.CompactDatabase strPathToMDB, strTempDB

Do I have to give the priviledge to run the
vbscript to the database password somehow?

There are only 2 user level passwords known to me.  The user does not
remember anything else.
One is admin and the other is developer.    The developer password has
the ability to change all objects except the database object.  The
admin user has access to all objects except in database object "modify
design".

I should be able to use the
database password to run the script so why does it  bring up the user
level password dialogue?

By the way it says source DAO.engine.  Does that mean I need to
install some library?  i don't really think so I think it is a
security issue but I don't know how to solve it.  thnx,
P.S.
Do I need to add these lines in my script?

set dbe = createobject("dao.dbengine.40)
dbe.SystemDB =:system.mdb"
dbe.DefaultUser= "user"
dbe.DefaultPassword = "pwd"
What is the difference between line 1 to create the dao.dbengine and
CreateObject("Access.Application.11") in my script?

--------script-------------

Option Explicit
Dim objScript
Dim objAccess
Dim strPathToMDB
Dim strMsg
Dim strTempDB

' ///////////// NOTE: User must edit variables in this section /////
'
' The following line of code is the only variable that need be edited
' You must provide a path to the Access MDB which will be compacted
'
strPathToMDB = "Z:\SwimClub\acsc_be.mdb"
'
' ////////////////////////////////////////////////////////////////

' Set a name and path for a temporary mdb file
strTempDB = "Z:\SwimClub\Comp0001.mdb"

' Create Access 97 Application Object
'Set objAccess = CreateObject("Access.Application.8")

' For Access 2000, use Application.9
Set objAccess = CreateObject("Access.Application.11")

' Perform the DB Compact into the temp mdb file
' (If there is a problem, then the original mdb is preserved)
On Error GoTo 0
objAccess.DBEngine.CompactDatabase(strPathToMDB,
strTempDB,";pwd=Kiyote#3")
If (Err.Number <> 0) Then
On Error GoTo 0
' There was an error. Inform the user and halt execution
strMsg = "The following error was encountered while
compactingdatabase:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
Wscript.Quit
End If
On Error GoTo 0

' Create File System Object to handle file manipulations
Set objScript = CreateObject("Scripting.FileSystemObject")

' Back up the original file as Filename.mdbz. In case of undetermined
' error, it can be recovered by simply removing the terminating "z".
objScript.CopyFile strPathToMDB, strPathToMDB & "z", True

' Copy the compacted mdb by into the original file name
objScript.CopyFile strTempDB, strPathToMDB, True

' We are finished with TempDB. Kill it.
objScript.DeleteFile strTempDB
Call MsgBox("compact successful")
 

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