CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 1999
    Location
    Malaysia
    Posts
    56

    Access Database Utilities

    Hi all,
    Here is a stupid post. If I wanted to compact my Access database (Access 97) via VB, how do I go about it? I've created a reference to the Access object, but am not sure how to call this command.
    Thanks for your help.


    ____________________________________
    The VB Bugs in my Life...

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Access Database Utilities

    add a reference to DAO to your project and call the CompactDatabase method of the DBEngine object.


  3. #3
    Join Date
    Dec 1999
    Location
    Malaysia
    Posts
    56

    Re: Access Database Utilities

    Hi again,
    Forgot to mention that I am using ADO and not DAO, and I did try the CompactDatabase method via the DBEngine, but VB kept complaining about the application being open.
    The question is, do I have to close my ADO connection first before doing this?
    Thanks again

    ____________________________________
    The VB Bugs in my Life...

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Access Database Utilities

    ok, try this: MSDN article Q230501 describes how to compact a database via ADO:
    you need to use "Microsoft Jet OLE DB Provider and Replication Objects (JRO). "
    which comes with Jet 4...
    check out the article it has all: source code and so on.


  5. #5
    Join Date
    Dec 1999
    Location
    Malaysia
    Posts
    56

    Re: Access Database Utilities

    Thanks Lothar,
    Found out why VB complained about my code. My ADO connection object was left open. So, I closed it and the code worked!!! Another bug I found was that I was compacting the database and used the same MDB file as the output.
    Thanks for your help!

    ____________________________________
    The VB Bugs in my Life...

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured