How to make and use file DSNs for Inmagic ODBC
There are three ways to set up a DSN for ODBC connections: System DSN, User DSN, and File DSN. The first two store the connection settings in the registry, while the third stores all the connection info in a text file. The latter can be easily copied, filed with its parent project, put in source control, and modified by a build process. Plus just having that file there is a reminder that an ODBC connection is an application requirement. (Oh, I *have* forgotten.)
Create the file DSN
You can create a file DSN by opening the ODBC Data Source Administrator dialog (listed as "Data Sources (ODBC)" from the Windows Start Menu), but I have encountered problems doing it that way.* It's easy to do from scratch, anyway.
- Create a text file with a .dsn extension: MyFileDsn.dsn
- Fill in the contents as follows:
1: [ODBC]
2: DRIVER=Inmagic DB/Text Driver (*.tba)
3: READONLY=1
4: SERVER=NotTheServer
5: DBQ=c:\project\textbases\
6: PWD=INMAGIC
7: UID=
Notes:
- Each key-value pair is on its own line separated by a carriage return. Ignore the fact that the view you're looking at on the blog may be wrapping.
- The Inmagic ODBC driver must be installed on any machine using this connection.
- ReadOnly can be set to 1 for readonly access. READONLY=0 means write access as well.
- PWD can be blank if the textbase(s) don't use passwords.
- UID is always blank.
* E.g. password not being written to the file DSN, and the potential for confusion between 64bit and 32bit ODBC Data Sources, since a 64bit machine has both and has separate Admin dialogs.
Use the file DSN
Pass a connection string to your application which points to the file you created:
1: // C# file DSN example
2: string connectionString = "filedsn=c:\MyFileDsn.dsn";