Why do I get error "Data source name not found and no default driver specified"?
- The data source you're attempting to connect to does not exist on your machine.
On Linux and UNIX,
SYSTEM
data sources are typically defined in/etc/odbc.ini
.USER
data sources are defined in~/.odbc.ini
.On Windows, data sources are created in ODBC Data Source Administrator. The available system data sources are listed in the System DSN tab. The user data sources that are available for the currently logged on user are listed in the User DSN tab.
Refer to your ODBC driver's documentation for information about how to create a data source and the connection details that you need to put in it.
- You don't have permission to access the location where the data source is stored.
On Linux and UNIX, you need read access to the
.ini
file that contains the data source.On Windows, the user account that is attempting to access the data source needs to have sufficient permissions to read the registry subkey where the data source is stored. System data sources are stored under HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI. User data sources are stored under HKEY_CURRENT_USER\Software\ODBC\ODBC.INI.
- On Linux and UNIX, your
SYSTEM
data sources or ODBC drivers are defined in non-standard files or locations and you have not set the relevant environment variable to tell unixODBC where to find them.You may need to set
ODBCSYSINI
,ODBCINSTINI
, orODBCINI
. For more information, refer to ODBC on Linux and UNIX platforms. - The data source is defined for another user.
User data sources are defined for a specific user.
- The
Driver
attribute is either missing from the data source or has an invalid value.The ODBC Driver Manager relies on the
Driver
attribute to know which ODBC driver to load. - The ODBC driver that the
Driver
attribute points to is not installed on your machine.On Linux and UNIX, to display a list of installed drivers, enter
odbcinst -q -d
.On Windows, the Drivers tab in ODBC Data Source Administrator lists the installed drivers.
- You're using a DSN-less connection in which the
Driver
attribute is missing, has an invalid value or points to an ODBC driver that is not installed on your machine. - You're attempting to access a remote data source that doesn't exist.
The remote data source specified in your ODBC-ODBC Bridge client data source (the
TargetDSN
attribute value) needs to exist on the machine (or machines) specified with theServerPort
attribute. - You're using a DSN-less connection on Windows that specifies a driver whose architecture is different to that of the application's. For example, you are using a 64-bit application, but the driver you specify in the connection string is only available as a 32-bit library. The application and ODBC driver architecture must be the same. (Although you can use the ODBC-ODBC Bridge as a solution if you're unable to get an ODBC driver with the same architecture as that of your application's.) For more information, refer to 64-bit ODBC.
- You're using SQL Server and are attempting to create a linked server:
- You're attempting to use a User ODBC data source. This only succeeds if the SQL Server instance is running under the same user account as the one used to create the data source. Otherwise, you must use a system ODBC data source instead.
–Or–
- You've installed the ODBC driver and configured the ODBC data source on the same machine as SQL Server Management Studio, however the SQL Server instance you're connecting to is on a different machine. The ODBC driver and data source need to be on the same machine as the SQL Server instance.
- You're attempting to use a User ODBC data source. This only succeeds if the SQL Server instance is running under the same user account as the one used to create the data source. Otherwise, you must use a system ODBC data source instead.
- You're using SAP BusinessObjects. You need to install your ODBC driver on both the BusinessObjects Server and BusinessObjects Client Tools machines. You need to create a system ODBC data source with the same name on both the BusinessObjects Server and BusinessObjects Client Tools machines. On 64-bit Windows, the BusinessObjects Server is a 64-bit application and the BusinessObjects Client Tools are 32-bit applications. On the BusinessObjects Server machine, you therefore need to configure the data source in the 64-bit version of the ODBC Data Source Administrator. On the BusinessObjects Client Tools machine, you therefore need to configure the data source in the 32-bit version of the ODBC Data Source Administrator.
- Your application is passing a connection string in an encoding that the Driver Manager cannot handle. For example, a UTF-8 encoded connection string is being passed to
SQLDriverConnectW
, which expects the UCS-2 encoding. You may be able to work around this by configuring your application to behave differently. For example, some versions of the Oracle Heterogeneous Services agent, DG4ODBC, supports the init file setting,HS_NLS_NCHAR = UCS2
, which causes it to pass UCS-2 encoded data to the ODBC APIs rather than UTF-8. Some ODBC driver distributions may include an ANSI-only version of the driver, which may cause your application to behave differently. For example, there is an ANSI-only version of Easysoft SQL Server ODBC driver, which has the suffix "_a":[MY_SQL_SERVER_ODBC_DRIVER_DSN] #Driver = Easysoft ODBC-SQL Server Driver = /usr/local/easysoft/sqlserver/lib/libessqlsrv_a.so