To compress an Access database on a Web page

Source: Internet
Author: User
Tags access database backup

Many years ago to the client database, using Access, has been two years, grow very large, 1G so big. As you continue to add, update, and change database design, database files become larger and bigger. The factors that cause the increase include not only new data, but also the performance of the database files as they are continuously populated by the legacy temporary objects and deleted objects. Symptoms include: The object may be turned on more slowly, the query may run longer than normal, and typical operations often seem to require longer periods of time.

So it is imperative to compress Access databases.

Really worry, if not careful, it is not saved. Fortunately, backing up an Access database is very simple, so just copy that file, and it's solved. Even, you can write an ASPX page, to perform this action, let me anywhere, as long as there is a network, you can use the Web page to do backup, even if I use ipad,iphone,android mobile phone can. Although it is a fuss, but a year to do a sessions, but, if you can not let customers worry about the situation, to complete these insurance, there will be a feeling of trust to them. Even if the computer is not automated to do, at least I do it automatically, is also automated Ah!

However, only backups are still insufficient, and the backup resolves only the first step of failure recovery. The next face is more and more old data, if not deleted, the file is more and more large, more and more time to query, really is meaningless waste of time. So, the next step is to do the removal of old data. However, this creates another unsatisfied. Although the data has been deleted, the query speed is back to the previous fast, but the size of the data file, still remain the same. It's really not happy to think about it.

With Office Access, you can open the MDB, and then compress the database in the "main function (left window)"->"manage"->"compression and Repair Database" feature.

To do so, you need to do it manually. and prepare a computer that has MS access installed.

This work, of course, can be done with instructions, but it's still going to execute the instructions on the computer that has MS access, and then use the work Scheduler to execute (reference).

C:Program Files (x86) Microsoft OfficeOffice12MSACCESS.EXE c:northwind.mdb/compact

If you want to do this with a Web page, you will not be able to do so because of some restrictions. Guessing is mainly because MSACCESS.exe is a desktop program. After the execution of the jammed, did not finish the work. This should only be a matter of setting up, because it can be used normally in the development environment. But in the environment of IIS, it is jammed. A reminder that the service program may not be able to interact with the desktop causes problems (references). I have tried this method is also a failure. We have tried before, if the console program is able to execute successfully.

In order to adhere to the Web implementation, looking for a long time, in the Microsoft Development Environment, will install a DAO. It's just a DLL. Just copy the Dao.dll in the bin and quote it. Just use two lines to get it done.

Dao. DBEngine dbe = new DBEngine ();

Dbe.compactdatabase (target_uncompact, target_compact, NULL, NULL, NULL);

If, the boss asks, why two lines of procedures to write fast two weeks, that ..., to please Cao's good friend to answer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.