How to determine the version of an MS Access file (.mdb) using C#

I need to find a way to determine which version of Microsoft Access an access fil e is? I know how to open an access file, but not to determine which version the .mdb file is. I need to know how to do this in C#.

 OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=jinkies;");
 
    try
    {
        con.Open();
    }
    catch
    {
        Console.WriteLine("DB Open failed!");
    }

LVL 2
brgdotnetcontractorAsked:
Who is Participating?
 
tsellsConnect With a Mentor Commented:
Are you trying to determine between Access 2000 and 2007?  If so just check the file extension.


using System.IO;
public enum AccessType
            {
                Access2000,
                Access2007
            }
        
        private AccessType GetTypeFromFile()
        {
            string path = @"D:\Path";
            FileInfo fi = new FileInfo(path);
            if (string.Compare(fi.Extension, "mdb") == 0)
                return Access2000;
            else if (string.Compare(fi.Extension, "accdb") == 0)
                return Access2007;
        }

Open in new window

0
 
brgdotnetcontractorAuthor Commented:
My apologies. I am trying to determine if an access file is version 1997 or 2000 that is what I need to determine.
0
All Courses

From novice to tech pro — start learning today.