Is it possible to "compact and repair" an Access database programmatically somehow (using ADOX, using OleDbConnection etc.)?
相关问题
- Importing data from MS Access db to PostgreSQL db
- DoCmd.TransferSpreadsheet is not recognizing works
- Is there a way to apply theme on converted access
- How to programmatically convert Access 1997 .mdb t
- Multiple (left, cross?) JOINs in MS Access
相关文章
- COALESCE, IFNULL, or NZ() function that can be use
- CurrentDb.RecordsAffected returns 0. Why?
- How to embed ms-access forms in C# module?
- Sleep Lib “kernel32” gives 64-bit systems error
- How to destroy an object
- Close all VBE windows (MS Access, VB for Aplicatio
- Compiling an Access 2007 accdb into accde
- MS Access VBA: turn query results into a single st
Sample code for VBScript.
I don't have enough rep to reply to a previous "answer", but I wanted to provide some info that might be helpful to someone else in regards to the OP's question.
I have been using the JRO method for years to compact/repair my Access 2000 databases from VB.net. Every once in a blue moon, I have a client that has managed to corrupt a database (usually when connected to the database over a network and they suffer an unexpected network interruption). JRO (in my experience) works fine, as long as the database IS NOT CORRUPTED. I never could figure out why the database COULD be repaired if I used the Access application to do it, but when using MY application (which uses JRO), the compact/repair would always fail (database is in an unrecognized format).
So, after coming across this thread just an hour ago, I dropped a reference to DAO into my app and tried out its ability to repair a corrupted database as I just today had a client corrupt their database (third time its happened in about 8 years). Guess what, DAO was able to repair the database when JRO failed!
OK, so that is my experience with JRO vs. DAO. Hope it helps. Here is a piece of sample code for using
CompactDatabase
from DAO:This solution works with the Access 2010 Database Engine:
Required reference:
Code:
(The sourceFilePath and destFilePath should not be the same!)
CompactDatabase method parameters (from reflection):
Make sure you run it under the same platform as the AccessDatabaseEngine (or Office) you installed (x86/x64).
Here is the official MS link, any further comments would be redundant. DBEngine.CompactDatabase Method
it'possible compacting and repairing an MS ACCESS database in two ways:
RepairDatabase()
, while in DAO360 there'sCompactDatabase()
As an example, in VB6 (old, old, old...) do this:
As you will notice, the function requires that you specify the name of the db to be repaired and the name of the repaired database.