Check to see if MySQL ODBC 3.51 Driver is installed

How can I check if MySQL ODBC 3.51 Driver is installed on a PC?

and if it is not installed, Install it?

Please help ASAP.
DickSwart6Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MirtheilSoftware DeveloperCommented:
Is this within an Install program or within your application?  Either way, you're going to want to check the ODBC registry key for the driver.  The base key is at:
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers
From there, you can check for the MySQL driver. It would be a String Value with the driver name as the name and "Installed" as the value.  If it's not there, you can call out to the ODBC driver install package.  
DickSwart6Author Commented:
Ok, How do I Do Both?

It will be better id I can do it when I Install the App, but if I have to I do it in the app itself.

Now the question is HOW?

MirtheilSoftware DeveloperCommented:
Which install tool are you using?  Most install tools offer a way to check a registry setting and then perform an action like launching an external program (like the ODBC Driver package).  
DickSwart6Author Commented:
Visual Studio Instaler, Where and how?
MirtheilSoftware DeveloperCommented:
I don't have VSI installed on my system so I'm not sure how it would work.   Personally, I use InnoSetup (http://www.innosetup.com).  Here's a simple InnoSetup script that does it.

;Script created by Mirtheil

#define MyAppName "My Program"
#define MyAppVerName "My Program 1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.mycompany.com"
#define MyAppExeName "MyProg.exe"

[Setup]
AppName={#MyAppName}
AppVerName={#MyAppVerName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DisableDirPage=Yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Run]
Filename: "{src}\mysql-connector-odbc-3.51.12-win32.msi"; Description: "MySQL"; Check: IsMySQLOdbcInstalled;

[code]

function IsMySQLOdbcInstalled(): boolean;
var
Installed: Boolean;
bRes : Boolean;
sExec : string;
ResultCode, iMsgRes: Integer;
Filename, Params: String;

begin
Result := false;
sExec := '';
bRes := RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\ODBC\ODBCINST.INI\ODBC Drivers',
     'MySQL ODBC 3.51 Driver', sExec);
if (not bRes) then
begin
  //It's not installed.
  MsgBox('Not Installed.', mbInformation, MB_OK);
  result := true;
end
else
begin
  //We want to double check that it is installed.
  if (sExec = 'Installed') then
  begin
    MsgBox('Installed', mbInformation, MB_OK);
    Result:= false; //We set it to false so the install isn't run in the "Run" section.
  end;
end;
end;

 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.