Question posted 2010 · +10 upvotes
I have a program which needs to upgrade any Access (Jet) database it opens to JET Version4.x if it isn’t already that version. (This enables use of SQL-92 syntax features)
Upgrading is (relatively) easy. A call to the JRO.JetEngine object’s CompactDatabase method (as described here) should do the trick, but before I do this I need to determine whether an upgrade is required. How do I determine the Jet OLEDB:Engine Type of an existing database? Can this be determined from an open OleDBConnection?
Note:
- I’m talking about database versions, not Jet library versions.
- C# or .Net solution greatly appreciated.
- This is an application which uses the Jet engine, NOT an Access application.
Accepted answer +4 upvotes
You’ll have to set a reference to ADO and then you can get the property.
From inside of Access
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
From outside of Access
Dim cnn As New ADODB.Connection
cnn.Open Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Contact.mdb
And finally
Debug.Print cnn.Properties("Jet OLEDB:Engine Type").Value
This .Value will return 1 to 5. If it is 5, it is already in Jet4x, otherwise it is an earlier version.
Here’s another example of the upgrade technique you’re looking at as well: Convert MDB database to another format (JET, access version)
3 code variants in this answer
- Variant 1 — 2 lines, starts with
Dim cnn As ADODB.Connection - Variant 2 — 2 lines, starts with
Dim cnn As New ADODB.Connection - Variant 3 — 1 lines, starts with
Debug.Print cnn.Properties("Jet OLEDB:Engine Type").Value
Top ms-access Q&A (6)
- How can I modify a saved Microsoft Access 2007 or 2010 Import Specification? +31 (2008)
- OleDbCommand parameters order and priority +28 (2009)
- Is there an equivalent to the SUBSTRING function in MS Access SQL? +26 (2009)
- What do I need to read Microsoft Access databases using Python? +25 (2009)
- MS Access library for python +24 (2009)
- is there any replacement of Access? +21 (2009)
ms-access solutions on this site
.