Read and write File ODBC data sources

A file DSN is nothing but a text file that contains all the parameters for an ODBC connection. To prove this, just go to the default directory that holds all File DSNs (this is the \Program Files\Common Files\ODBC\Data Sources directory on Windows's boot drive) and load any .dsn file into a text editor such as Notepad. For example, this is the typical contents of such a file:

That said, it's pretty easy to manually write a Visual Basic procedure that creates a File DSN. For example, the following routine creates a connection to any database on the local SQL Server, using the provided username and password: