Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 196809 - Last Review: February 12, 2007 - Revision: 3.1
PRB: CompactDatabase Method Requires Locale to Convert 2.0 MDB
This article was previously published under Q196809
On This Page
SYMPTOMS
When attempting to use the Data Access Object (DAO) 3.5 CompactDatabase
method to convert a Jet 2.0 .mdb file to a Jet 3.0 file format, the
resulting .mdb file is still in a Jet 2.0 file format.
RESOLUTION
DAO 3.5 requires you to provide explicitly the locale argument of the
CompactDatabase when converting .mdb file formats.
STATUS
This behavior is by design.
MORE INFORMATION
Both Microsoft Jet 3.0 and 3.5 use the same file format, which is a
different file format than the format Jet 2.5 or earlier used. You can
convert a .mdb database using the CompactDatabase method of the DAO
DBEngine object.
Using DAO 3.0 and 3.5 (for Jet 3.0 and 3.5 respectively), you can convert
the .mdb database as follows:
DBEngine.CompactDatabase "20.MDB", "30.MDB", dbLangGeneral, dbVersion30
However, if you leave out the locale argument (dbLangGeneral in this case),
only DAO 3.0 converts the database:
DBEngine.CompactDatabase "20.MDB", "30.MDB", , dbVersion30
Steps to Reproduce Behavior
- With Microsoft Visual Basic 5.0 or 6.0, or with Microsoft Access 97 or
other Microsoft Visual Basic for Applications 5.0 or Microsoft Visual
Basic for Applications 6.0 applications, create a new project.
- From the Project menu, choose References and add a reference to the
Microsoft DAO 3.5 Object Library.
- Add a form (Form1) with a command button (Command1) and place the
following code in the form's module:
Option Explicit
Private Sub Command1_Click()
Const dbPath = "C:\Program Files\ACCESS20\SAMPAPPS\NWIND"
Dim db As Database
Set db = DBEngine(0).OpenDatabase(dbPath)
Debug.Print dbPath & " Version:", db.Version
db.Close
DBEngine.CompactDatabase dbPath & ".mdb", _
dbPath & "30.mdb", _
, _
dbVersion30
Set db = DBEngine(0).OpenDatabase(dbPath & "30")
Debug.Print dbPath & "30 Version:", db.Version
db.Close
Kill dbPath & "30.mdb"
End Sub
NOTE: You must change the dbPath variable to point to a Jet 2.x database.
- Run the project, open the form, and click the command button. You should get the following output:
C:\Program Files\ACCESS20\SAMPAPPS\NWIND Version: 2.0
C:\Program Files\ACCESS20\SAMPAPPS\NWIND30 Version: 2.0
- Replace the CompactDatabase line with the following and run the project again:
DBEngine.CompactDatabase dbPath & ".mdb", _
dbPath & "30.mdb", _
dbLangGeneral, _
dbVersion30
The second time you run the project, the output will be as follows:
Program Files\ACCESS20\SAMPAPPS\NWIND Version: 2.0
Program Files\ACCESS20\SAMPAPPS\NWIND30 Version: 3.0
REFERENCES
Microsoft Visual Basic Help; search on: "CompactDatabase Method".
APPLIES TO
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
- Microsoft Visual Basic for Applications 5.0
- Microsoft Visual Basic for Applications 6.0
- Microsoft Access 97 Standard Edition
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please