How to register ODBC driver? - database

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.

You can use the odbcconf command to register the driver dll directly. Note there're both 32 bit and 64 bit ODBC drivers, so you will need to use the respective odbcconf command.
For example to install 64 bit ODBC driver on 64 bit machine:
odbcconf /A {INSTALLDRIVER "My Driver Name|driver=Path to my driver dll"}
To install the 32 bit driver on 64 bit machine:
%systemroot%/systemwow64/odbcconf /A {INSTALLDRIVER "My Driver Name|driver=Path to my driver dll"}
You can find more about the odbcconf command at Microsoft Docs

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":
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:
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:
SQLInstallDriverEx archive
SQLRemoveDriver archive
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:
SQLGetInstalledDrivers archive

What I would recommend for you is to create a bootstrapper installation package. You didn't mention the platform you are delivering for, but since you are writing about installers I will assume that the platform is Windows.
There are multiple installer frameworks you can use to create installers for your software on Windows, but the one I recently used and would recommend is WixToolset. They have some documentation on how to build bootstrapper bundles here
In great simplicity my wix bootstrapper came down to installing one exe installer and one msi installer and the configuration looked something like this (in great simplicity - the link I provided has full documentation on how to configure all the features)
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Version="..." Name="...">
<Chain>
<ExePackage Id = "x86redist" SourceFile="..." ... />
<MsiPackage Id = "myApp" SourceFile ="..." ... />
</Chain>
</Bundle>
</Wix>
in the end after building, my bootstrapper bundle looked like this
and made sure both my software and the redistributable package were installed on the machine when it was finished.
You could use exactly the same approach - the bundle could install the odbc driver using its original installer, and then install your software.

Related

Why am I getting "Data source name not found and no default driver specified" and how do I fix it?

When trying to make a program on Windows that connects to a database via ODBC, I got the following error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
I'm sure my code is right. It even worked on a different PC.
Why am I getting this error? And How do I fix it?
What causes this error?
The error message tells you, simply put, that the ODBC Driver Manager could not find the driver you specified in your connection string or DSN.
This can have 3 common causes:
The driver you tried to use is not installed on your system
The driver is installed, however, it doesn't match bitness of the code you're running
You made an error in typing the driver name
How do I check which drivers are installed on my system?
You can check the drivers which are installed on your system by going to the ODBC Data Source Administrator. To open it, press ⊞ Win + R, and type in: odbcad32.exe. Then check the tab Drivers for installed drivers. The Name column indicates the exact name you should use in your connection string or DSN.
If you're on 64-bit Windows, that only lists the 64-bit drivers installed on
your system. To see which 32-bit drivers are installed, press press ⊞ Win + R, and type in: C:\Windows\SysWOW64\odbcad32.exe, and go to the Drivers tab again.
The driver is installed, but it might be the wrong bitness, what do I do?
Then, you have two choices, either adjust the bitness your program is running in, or install a driver with a different bitness.
Some of the drivers that are installed by default on Windows only have a 32-bits variant. These can't be used with 64-bits programs.
You can usually identify which bitness a program is running under in task manager. In Windows 10, all 32-bit programs have (32-bit) appended to their name. If that isn't there, you're likely running a 64-bit program, and most modern programming languages and environments run on 64-bit by default, but allow you to switch to 32-bit. However, the specifics for different programming languages are outside the scope of this question.
How can I verify I didn't mistype the driver name?
An ODBC connection string looks like this:
DRIVER={DriverName};ParameterName1=ParameterValue1;ParameterNameN=ParameterValueN;
The driver name part needs to be delimited by curly braces if it might contain special characters, and needs to exactly match the installed driver name, as found in the ODBC Data Source Administrator, including spaces and typographical characters, but excluding capitalization.
Note that for deployed code, the driver must be present on the computer/server running the code.
I don't have the driver, or have the wrong bitness, where do I get the right one?
That depends on which driver you want to use.
A list of common drivers with download locations (all 32-bit and 64-bit at the same URL):
The Microsoft ODBC Driver 17 for SQL Server
The Microsoft Access database driver, which is part of the Microsoft Access Database Engine. Note that simultaneous installations of 32-bit and 64-bit Access ODBC drivers are not supported.
The MySQL ODBC connector by Oracle
The open-source SQLite ODBC driver by Christian Werner (non-official)
psqlODBC, the official PostgreSQL driver
If the driver you want to use isn't listed, the location is usually easily found using Google.
In design mode, a value has been set to the property of
TFDConnection.ConnectionDefName must be empty.

Connect to Ms SQL with RODBC without dsn

I'm trying to set up a connection from ubuntu to mssql server with the RODBC package.
I did make it work with RJDBC but read the speed might be much slower than ODBC so I wanted to test it.
I don't have a dsn available, ip port databasename usr pwd is all the information I can use.
The code used with RJDBC which works is:
drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
"/media/sqljdbc4.jar")
RJDBC::dbConnect(drv, 'jdbc:sqlserver://ip:port;databaseName=databasename', 'usr', 'pwd')
Tried alot around browsing different syntaxes but could not make it work.
RODBC::odbcDriverConnect('driver={SQL Server};server=ip:port;database=databasename;uid=usr;pwd=pwd)
Gives me the error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
Do I need to download drivers to the ubuntu machine? Thought they were included with the package.
The RODBC package doesn't include drivers. That would be unwieldy given how many possibilities there are.
see https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf
"connection to the particular DBMS needs an ODBC driver : these may
come with the DBMS or the ODBC driver manager or be provided
separately by the DBMS developers, and there are third-party
developers"
Microsoft provides drivers for Ubuntu:
https://www.microsoft.com/en-us/download/details.aspx?id=50419
You can add dsn entries to the /etc/odbc.ini file in most linux distros. See this for ubuntu https://help.ubuntu.com/community/ODBC

Connecting to database via ODBC

I have running a 32-bit software(Lexware) running on a 64-bit server that uses SQL Anywhere 12 database. Several clients a connecting via ODBC to this database.
After one employee updated the server one client stopped working correctly. PyOdbc gave the message that the architecture of the driver does not correspond the the one of Lexware.
It seems that I am using the 64-bit ODBC driver, which does not work with a 32-bit Lexware. So I tried to use the 32-bit ODBC driver. The client is using Windows7 64-bit.
I went to the 32-bit ODBC Data Sources
Clicked on Add
Chose "SQL Anywhere 12"-driver
Clicked Finish
Then an error messages appears: "The setup routines for SQL Anywhere 12 could not be found. Install the driver again."
I click ok. Another message appears. "Error found: Component could not be found in the registry.
I then installed the whole sybase drivers again.
But I get the same error. I do not know what to do anymore. I also tried several other things. What I find curious is that everything worked before. All the other clients also work. Just this one does not. I need this to work for my company.
How can I fix this?
You need to install the 32-bit version of the Lexware ODBC drivers. You also need to install the 32-bit version of the client you are using to query the databases.
You cannot mix 32 and 64 bit code in one process.
I found the solution.
Under "HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/ODBC/ODBCINST.INI/SQL Anywhere 12"
The Strings "Driver" and "Setup" were missing. I added the path to the 32-bit ODBC drivers. Now everything works again.

pentaho local and remote connection to sql server

This is giving me headache.
I just set up pentaho community edition on my laptop. I was able to connect to mysql server in xampp by following the instructions in the pdf documentation that comes with the enterprise edition getting_started_with_pentaho. I connect perfectly to mysql database.
However I need to also connect both locally and remotely to a sql server (mssql) but follwing the same process as i did for the mysql database does not work.
This is what i did:
I installed SQLServer2008R2SP1-KB2528583-x64-ENU.exe sql server and logged in successfully with the following input
server type: database engine
server name: ME-PC\SQLEXPRESS
authentication: windows authentication
login: ME-PC\ME
password:
Now I downloaded the jdbc driver for mssql from here and extracted the folder to my desktop. The folder contained sqljdbc4.jar and sqljdbc.jar as well as both x64 and x86 versions of sqljdbc_auth.dll.
I am running a x64 OS but but the jdk i installed went to the Programfiles(x86) so I guess the java i had install was for x86. Due to this reason I copied sqljdbc4.jar and the x86 version of sqljdbc_auth.dll to the directorys:
C:\Users\ELRAPHA\Desktop\PENTAHO\biserver-ce\tomcat\webapps\pentaho\WEB-INF\lib
C:\Users\ELRAPHA\Desktop\PENTAHO\administration-console\jdbc
C:\Users\ELRAPHA\Desktop\PENTAHO\data-integration\libext\JDBC
I also enabled TCI/IP on my local sql server.
As I mentioned, am able to connect to sql server via the management studio but when i try to create a new connection through pentaho in the web browser with the following
hostname: localhost
database name: master
instance name: ME-PC\SQLEXPRESS
port: 1433
username: ME-PC\ME
password:
I get the error
error connecting to database [mssqllocal]
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
error connecting to database:(using class com.microsoft.sqlserver.JDBC.SqlServerDriver)
The TCP/IP connection to the host localhost, port 1433 has failed.
Error: Connection refused: connect.
I dont get what am doing wrongly especially since mysql was to straight forward. Been at this all day. I need help . Please can anyone see my error or something that am missing here? HELP
If you want to connect through JDBC to SQL Server via Windows Authentication, then the sqljdbc_auth.dll must be in the right location. On my system (x86) that this is relative to the install directory of the sqljdbc4 driver. By "extracted the folder to my desktop" I assume you mean you ran the installer, and that's where you choose the location of the driver. For example on my system, this file is not in the Pentaho folders, it's in:
C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\auth\x86
I would ensure that both 32 and 64 bit versions of sqljdbc_auth.dll are in their respective locations since you seem to have a mixed system.
Alternatively, you can use SQL Server authentication which is simpler, but doesn't integrate with AD, etc.
EDIT:
Oops, I forgot something very important. The JVM must be made aware of the location of sqljdbc_auth.dll. I had to add the path of that dll to %LIBSPATH% in Spoon.bat (I'm only using PDI).
So essentially I changed this block of code in the batch file:
:USE32
REM ===========================================
REM Using 32bit Java, so include 32bit SWT Jar
REM ===========================================
set LIBSPATH=libswt\win32
GOTO :CONTINUE
:USE64
REM ===========================================
REM Using 64bit java, so include 64bit SWT Jar
REM ===========================================
set LIBSPATH=libswt\win64
set SWTJAR=..\libswt\win64
to this:
:USE32
REM ===========================================
REM Using 32bit Java, so include 32bit SWT Jar
REM ===========================================
set LIBSPATH=libswt\win32;C:\PROGRA~1\MICROS~1.0FO\sqljdbc_4.0\enu\auth\x86
GOTO :CONTINUE
:USE64
REM ===========================================
REM Using 64bit java, so include 64bit SWT Jar
REM ===========================================
set LIBSPATH=libswt\win64
set SWTJAR=..\libswt\win64
Note the shortened path names. In your case, I would add an entry for the 64 bit lib also since you have a mixed environment.
Essentially whatever program you're starting that uses the sqljdbc driver, you must add the path the sqljdbc_auth.dll to the Java library path (i.e. -Djava.library.path=%LIBSPATH%). After doing that, my instance of PDI can connect to SQL Server via Windows Authentication with no trouble. I don't use the BI_Server or the Admin Console, but I suspect you'll have the same issue.
Note, I have no experience with SQLEXPRESS, or a mixed 32 bit JVM/64 bit OS environment. There could be problems there too, but if you want to use Windows Authentication with SQL Server, you have to at least deal with the library path issue.
If you are using a intance of Sql Express in local machine and connecting Pentaho, you must empty the field Port Number. Try the configuration below:
Host Name: localhost
Database: database_name
Instance Name: sqlexpress
Port Number:
User Name: user_name
Password: *****
In case of having issues, together with empty the port number, is to manually set the instance name as a manual parameter:
instanceName=SQLEXPRESS
The default pentaho dialog (at least to 8.3) generates only the code "instance=SQLEXPRESS"

files needed for deploying delphi 2010 with ms access 2007 and ado for database connection

I'm building database application with delphi 2010 in which the database i used is ms access 2007 and ado as the connection....
then, i used installshield express from delphi 7 to do the deployment....
i open the setup file in my computer and there is no problem with it..but when i open the setup file in client computer, there is some error...
what makes me confused is what files needed to be added in the setup file for the deployment?
i've installed mdac 2.8 sp1 in the client, but it's still not working...
the error messages i got are : [microsoft][ODBC MIcrosoft Access Driver] general error unable to open registry key temporary (volatile) Ace DSN for process 0x16c8 thread 0x628 DBC 0x 3dc7eec
[micorsoft][ODBC Driver Manager] Data source name not found and no default driver specified..
then, when i try to another client computer, the error message i got are: [Microsoft][ODBC Microsoft Access Driver]'(Unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides
Exception EOle Exception in module 'module_name'.exe at 001A26AC
that's all the error messages i got... any clues?
Are you using the ACCDB format files? If so the version of ADO that comes with Windows knows nothing about that file format. You will need to install 2007 Office System Driver: Data Connectivity Components I would suggest using an MDB format file unless you are using some of the Access 2007 specific features as ADO knows all about MDB format.
It's very doubtful you'd need to install MDAC on the client system so long as it's Windows XP SP3 or newer. Windows XP SP2 installed MDAC 2.8 SP1. So don't much with the ADO version. For some information on how ADO works at the version level see I've never quite trusted ADO because … That article is written from the Access perspective but should give you some useful information on ADO versioning.
Perhaps the ADO connection component in your app has it's Active property set to true, or is set to true on startup, but the connection string is not valid on client machines as opposed to your dev machine? In this case you would receive a connnection error.
Without the error message it's hard to tell as jachguate says, but theoretically you should not need anything additional to deploy it according to the information you have provided.
As already said, without more information, it's hard to tell.
Please read and follow the advices on writing a good question by Jon Skeet.
It will boost your chances of getting an actionable answer...
Three basic things you need for connecting to Access:
the Data access layer: you should have it covered with installing MDAC.
the DB itself: either you create it from your application or the DB must already exist on the target machine. If not, you must deploy the DB files.
the connection to the DB: you must ensure the ConnectionString is valid for the target machine and you don't try to connect or activate any dataset before it is checked.
This is working now.
I installed 2007 Office System Driver: Data Connectivity Components as Tony recommended, then I also added midas.dll to system32 on the client computer.

Resources