Easysoft Blog

Thu, 01 Feb 2018

Using isql with a Connection String

By default, the ODBC test application isql connects to a named ODBC data source, which you pass to isql on the command line. If you want to override settings in the data source, you can, by default, only pass a different a user name and password. If you want to use isql to connect using a different set of connection parameters, you can either create a new data source or use isql's -k option and pass the application a connection string.

The latter approach means that you can connect without affecting your existing data source, avoiding disruption to other applications, and keep the number of data sources you have down to a minimum.

To enable a connection string (also known as a DSN-less connection) to be passed to isql, the -k option, changes the ODBC API function that isql uses to connect. By default, isql uses SQLConnect, which accepts a data source name and a user name and password. If you include -k on the command line, isql uses SQLDriverConnect instead. This function accepts:

Examples:

Connects to a data source:

isql -v -k DSN=MyDSN

Connects to a different database to the one specified in the data source:

isql -v -k DSN=MyDSN;Database=NewDB

Uses a DSN-less connection:

isql -v -k "DRIVER={Easysoft ODBC-SQL Server SSL};Server=machine\sqlserver_instance;
                              UID=user;PWD=password;Database=database_with_always_encrypted_data;ColumnEncryption=No"