Sqlite – How to register ODBC driver

connectordatabaseodbcsqlite

I have created a inventory system for my school project and I use SqlLite as standalone DB. I am able to run it as long as I install the SqlLite ODBC connection (separate installer).

But what I want is to create an installer and install the SqlLite ODBC Drivers along with my porject in one installer instead of of running two separate installer (my application and sqlLite ODBC driver installer).

Any idea how to do it? Or do you have any recommendation?

What I have done so far. I copy the SQLLite ODBC dll into my application folder and run it but an error shows telling that no ODBC driver installed. I failed to register the SqlLite odbc dll on both 32 and 64 bit windows OS.

Best Answer

It was difficult to find, so i'm going to add it as an answer here on Stackoverflow. I knew the answer from spelunking the registry, but i wanted the supported method.

From Registry Entries for ODBC Components archive, we learn ODBC drivers are registered in the registry.

  • HKEY_LOCAL_MACHINE
    • SOFTWARE
      • ODBC
        • Odbcinst.ini
          • ODBC Drivers

will contain a value for each driver equal to "Installed":

enter image description here

So you would need to create something like:

HKLM\SOFTWARE\ODBC\Odbcinst.ini\ODBC Drivers
    "SqlLite": REG_SZ = "Installed"

For each driver, there will then exist an

  • HKEY_LOCAL_MACHINE
    • SOFTWARE
      • ODBC
        • Odbcinst.ini
          • [Driver name]

In this folder is a series of Driver specifications:

enter image description here

Microsoft documents these items quite nicely in the Driver Specification Subkeys archive page on MSDN.

In the case of an SqlLite ODBC driver that would mean there is a key called:

HKLM\SOFTWARE\ODBC\Odbcinst.ini\SqlLite

and you would have to be sure to create all the values for the SqlLite ODBC driver.

But don't do that

Another item in the driver details is a reference count (called UsageCount). This Usage Count is not meant to be fiddled with by people; but instead is updated when you call the functions:

So while you can push stuff into the registry yourself, you should be calling the documented API SQLInstallDriver.

And while it's probably safe to read the registry to see what drivers are installed, the documented say to get the list of drivers is:

Related Topic