Integrating MyODBC driver with application is another way & become my favorite trick when I did a client server project from Delphi. There are some reason why I still use ODBC & integrating it to the main program. First, I don’t even suspended with 3rd party component for expanding or future application release. All I need is only BDE & Data Access component. Then, I feel free to compile the codes wherever the native component & compiler exist. My application can also deployed smoothly even from Linux (with emulation engine) because nothing complicated API’s driver involved. Other advantages is, my client only need to installing a single setup software (including BDE’s & MySQL ODBC driver).
Based on my researches before, CMIIW - MyODBC driver just work with a single library file (myodbc3.dll) & some parameters planted in Windows registry. So, anyone can build their custom ODBC wizard & replace the functionality of standard MyODBC setup. There are 2 fixed registry track path of MyODBC driver & below is each of it:
The trick to integrating it is so simple as you have to create similar registry value according the above parameters. And don’t forget to take the myodbc3.dll library file taken from original MyODBC setup. Below is a sample in Delphi on how to create & integrating the driver into the application:
AppIni := TIniFile.Create('odbc.ini');
AppIni.WriteString('ODBC 32 bit Data Sources',eddbname.Text,'MySQL ODBC 3.51 Driver (32 bit)');
Reg.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',true)
Reg.WriteString(eddbname.Text,'MySQL ODBC 3.51 Driver');
Reg.OpenKey('SOFTWARE\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver',true)
Reg.WriteString('MySQL ODBC 3.51 Driver','Installed');
To make it more portable & dynamic, I suggest to save each of variable parameter into an encrypted text file. Here below is the sample of my own ODBC driver custom wizard:
That’s all, dude. Once you can build your custom MySQL ODBC driver, you will never need a standard MyODBC setup wizard. So that your users will feel more comfortable to the using of the application.
PS: If you've benefit from this blog,
you can support it by making a small contribution.