Determine the version number of your MDAC installation

© copyright 17.Jul.2008 by Paul Bradley posted under VB.


MDAC

Introduction

At Carlisle Software Ltd we recently deployed an updated database application to a large client site with over 1,000 computers. The update required that the latest version of the Microsoft Data Access Components (MDAC 2.8) was installed on the local machines, and the client informed us that around 5% of the computers had earlier version of the MDAC installed, but they couldn’t tell us which five per cent.

So we had to build an MDAC version checking function within the software’s start-up routine, so that we could detect the installed version number, and prompt the user with an appropriate error message if the version was less than 2.8

It’s all in the registry

Luckily the version number of the installed MDAC components is held within the Windows registry at the following key :-

HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess\FullInstallVer

So we just needed some Visual Basic 6 code to read the registry key value, and ended up using this GetRegistryValue function. Simply copy and paste the code into it’s own module within your project.

You will need to add a constant for the HKEY_LOCAL_MACHINE value to your project as shown below.

Public Const HKEY_LOCAL_MACHINE = &H80000002

Create an MDACversion() function

Next you need to create a function that returns the version number as Double, as its stored as a string within the registry. We do this so that we can do a math operator check against the returned value.

Public Function MDACversion() As Double

    MDACversion = 0
    MDACversion = CDbl(Val(GetRegistryValue(HKEY_LOCAL_MACHINE, _
        "Software\Microsoft\DataAccess", "FullInstallVer")))

End Function

Using the MDAC version function

Below is the code that we implemented into the startup routine of the new database software. It checks to see if the version number is less than 2.8, and presents the user with an appropriate error message before terminating the loading process.

If MDACversion < 2.8 Then
    MsgBox "Please contact the IT service desk, " _
        & vbCr & "and ask for version 2.8 of MDAC" _
        & vbCr & "to be installed on this machine.", _
        vbCritical + vbOKOnly, "Wrong version of MDAC installed"
End If

MDAC downloads

You can download the latest version of the MDAC from the Microsoft website.

§


Please consider linking to this page, by sharing it with others using social sites like del.icio.us, Stumble Upon or Twitter or by emailing it to your friends.


Other Popular VB Articles