File DSN default location?


  • In XP, I believe the default location for file DSN's was C:\Program Files\Common Files\ODBC\Data Sources. In Windows 7, when running odbcad32.exe and creating a file DSN, the default location that it's saved to is My Documents. In fact, the ODBC directory no longer exists under Common Files. This seems counter intuitive for a file that is (or was) considered accessible among all users of a computer in the past. You'd think that if Microsoft were going to change the default path, that it would be to the Public Documents folder so that the expected functionality of 'accessible by all users' would still hold true.

    Is there any documentation from Microsoft on where the default File DSN location should reside on a local drive in Windows 7 (and perhaps Vista), and why this behavior has changed? It almost seems as if Microsoft is discouraging use of File DSN's.

    Wednesday, August 17, 2011 11:06 PM

All replies

  • You can save the dsn file just about anywhere, both from the ODBC administration applet and using the SQLWriteFileDSN API, as long as you have write access to the target location. If you are only enumerating DSN files in the default folder you can miss out files saved elsewhere, e.g. an installer may install the file dsn to the app's folder under program files.

    If you are enumerating DSN files saved under the default folder, first look under HKCU\Software\ODBC\odbc.ini\ODBC File DSN\DefaultDSNDir, then look under HKLM\Software\ODBC\odbc.ini\ODBC File DSN\DefaultDSNDir. If no entry found under both places, go to my documents and search there.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Thursday, August 18, 2011 12:02 AM