Access Structure

  • Thread starter Thread starter Craig Ison
  • Start date Start date
C

Craig Ison

I need to determine what version a .MDB file is.
I would like to open the file as a stream and read the header to determine
this.
Where can i find info about this?
Im using VB.NET 2003..

Thank..
 
Microsoft have never publicly documented the MDB format, Craig, so there is
no official, supported source for this information. You *might* be able to
find an unofficial, unsupported source somewhere (though I've never heard of
one) but of course if you do there will be no reason to expect it to
continue to work with the next version of Access.

If you're just dealing with data in MDB files, I don't think it should
matter - the OLEDB.Jet.4.0 data provider should work with any Jet 4 MDB
(Access 2000 or later). Jet 3.x is, as I understand it, not supported. If
you're automating Access, the example below may help. This is a VB.NET
console app with a reference added to the Microsoft Access 11 Object Library
....

Module Module1

Sub Main()

Dim app As New Microsoft.Office.Interop.Access.Application
Dim strFormat As String

app.OpenCurrentDatabase("C:\Dataset\DSCCHECK.MDB", True)
Select Case app.CurrentProject.FileFormat
Case
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess2
strFormat = "Microsoft Access 2"
Case
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess95
strFormat = "Microsoft Access 95"
Case
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess97
strFormat = "Microsoft Access 97"
Case
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess2000
strFormat = "Microsoft Access 2000"
Case
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess2002
strFormat = "Access 2002"
End Select
app.CloseCurrentDatabase()
app.Quit()
Console.WriteLine("This is a {0} project.", strFormat)
Console.ReadLine()
 
Thanks for the reply. I have a distributed vb6 app that uses access97 files
and am creating a new version that uses access2000 files.. i wanted to check
the file for version to ask if they wanted to upgrade it to 2000 (therefor
making it unuseable with the old version). I have to problems reading either
but i cant tell which version it is...
 
I need to determine what version a .MDB file is.
I would like to open the file as a stream and read the header to determine
this.
Where can i find info about this?
Im using VB.NET 2003..

Thank..

You can get the version of JET being used with DBEngine.Version (3.6
for A2002) - I seem to remember a way to determine the version of
Access that was used to create the database but can't put my hands on
it right now, but for VB.NET purposes the JET version may be more
important anyway. Hope this helps!
 
How about adding a single-record, single-field table to the new Access 2000
MDB, and using it to store your own version number? At runtime, check to see
if the MDB contains that table. If it doesn't, you'll know it's the old
Access 97 MDB.
 
Craig Ison said:
I need to determine what version a .MDB file is.
I would like to open the file as a stream and read the header to determine
this.
Where can i find info about this?

I saved the following from a posting a while back. I'm sure you can
locate it by searching on google. However that URL no longer works
and I can't find the file. I've emailed Mike from MS to see if he can
recall the file name or such.

Tony

Thanks Mike! That's a great start, but it doesn't seem to be very
comprehensive. Basically the algorithm seems to be:

If 1st byte = 01 then Access 2
ElseIf 21st byte = 00 then Access 97
ElseIf 21st byte = 01 then Access 2000/2002
Else Unknown

I ran it across a selection of old and new DBs I have lying around and found
that most V1 and V1.1 mdbs satisfy the V2 criteria, and there are also quite
a few "Unknown"s, most of which are V2. Most V1.x/V2 databases seem to be
all zeroes for the first block or so, except for the 01 in the first byte.
However, some have a lot of data in that block. I have a V2 mdb with &h77
in byte 1 and &hCF in byte 21!

Also, there's no distinction between 95/97 (as well as 2K/XP).

http://msdn.microsoft.com/downloads...s/027/001/683/msdncompositedoc.xml&frame=true if you're interested.
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Back
Top