Results 1 to 5 of 5
  1. #1
    DAW
    Guest

    JRO CompactDatabase Method

    Please has anybody got any code demonstrating how to compact a database that is proptected with user level security, using the JRO JetEngine.CompactDatabase method?

    I have been trying to use the following code as per MSDN/MSKB/Technet articles. JetEng has been declared as a New JRO.JetEngine object:-

    JetEng.CompactDatabase Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Database & ";Jet OLEDB:System Database =" & Mdw & ";Jet OLDEDB;User ID:=" & sUserID & ";Jet ODLEDB:Password=" & sPwd, _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPathName & "Backup.mdb;Jet OLEDB:System Database = " & Mdw & ";Jet OLEDB:User ID =" & sUserID & ";Jet OLEDB:Password= " & sPwd & ";Jet OLEDB:Engine Type=4"

    Thanks

    Dave.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: JRO CompactDatabase Method

    Is Database a variable?
    <hr>Data Source=" & Database & ";<hr>
    I would suggest using a different variable name, since that is the name of a DAO object. And try inserting the "Jet OLEDB:" qualifier ahead of "Data Source" to see if that makes a difference.
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: JRO CompactDatabase Method

    By the way, what kind of error are you getting? Your user needs to have adequate permissions in both Access security and network security to actually write the compacted database, so make sure that's the case. If you have guest users and this code is supposed to run, you'll have to run it using the administrator's login and password or trap the resulting error and handle it appropriately.
    Charlotte

  4. #4
    DAW
    Guest

    Re: JRO CompactDatabase Method

    Thanks Charlotte,

    In the end I fixed the problem by changing the code to the following:-

    JetEng.CompactDatabase Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Database & ";Jet OLEDB:System Database =" & Mdw & ";User ID:=" & sUserID & ";Password=" & sPwd, _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPathName & "Backup.mdb;Jet OLEDB:System Database = " & Mdw & ";User ID =" & sUserID & ";Password= " & sPwd & ";Jet OLEDB:Engine Type=4"

    The difference is that I have removed the 'JET OLEDB:' bits from the parts of the string that were setting the UserId and Password properties.

    Thanks

    Dave.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: JRO CompactDatabase Method

    Ah, I see. I hadn't paid full attention to that in your original post. The "Jet OLEDB:" string is only a part of the property name for Jet provider-specific properties. None of the pre-defined properties in ADO have a provider qualifier, and all of the provider-specific properties do.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •