Question & Answer
Question
Creating and using a file data source name (DSN) with a CLI/ODBC application
Answer
Follow these steps in order to create a file DSN on Windows:
1. Open the Windows ODBC Data Source Administrator
2. Choose "File DSN" tab
3. Choose "Add" button
4. Follow the prompts in the wizard
5. Save the DSN file by providing a path and file name
How is a file DSN created on Unix?
On UNIX, there is no ODBC Data Source Administrator, so a UNIX File DSN must be created manually using a text editor. It is also possible to create a File DSN on Windows, copy this file to UNIX , then use a text editor to manually update the file contents with the correct information.
What should a DSN file Contain?
At the top of the DSN file must be the following heading:
[ODBC]
The remaining lines in the File DSN should contain CLI/ODBC keyword=value pairs. Many CLI/ODBC keywords are driver-specific so the CLI/ODBC vendor documentation should be referenced in order to determine which keywords to use.
Here is an example of the contents of a file DSN file
[ODBC]
DRIVER=IBM DB2 ODBC DRIVER
UID=myuid
DBALIAS=mydb
MODE=SHARE
How do I use a File DSN in a CLI/ODBC Application?
In order to use a File DSN with a CLI/ODBC application, the CLI/ODBC keyword FILEDSN must be placed in the CLI/ODBC connection string.
Here are examples of connection strings that use a File DSN
"FILEDSN=c:\myprod.dsn"
"FILEDSN=c:\myprod.dsn;UID=myuserid;PWD=mypwd"
It is important to note that the keywords DSN and FILEDSN are mutually exclusive. So, if your connection string contains the CLI/ODBC keyword "FILEDSN", it cannot contain the keyword "DSN", and vice versa.
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21143820