ODBC: Sage 50 data, switching between companies without editing the DSN

Applies to: Sage 50 2009 data through its ODBC driver ("Sage Line 50 v15" DSN); Clarion version not named.

Problem

The app reads Sage 50 files through a DSN that holds the path to one company's data. A multi-company licence has other companies in sibling folders (Company.000, Company.001). Editing the DSN path by hand works but is a chore each time.

Solution

  1. Multiple DSNs only moved the problem: the DSN name is fixed in the dictionary and needed a recompile to change.
  2. Use a DSN-less connection. Make a File DSN, test it, open it in Notepad and join its lines with ; to get the connection string (the File DSN folder differs between Windows versions).
  3. In the dictionary set the Owner Name of each Sage table to a variable, !GLO:ConnectionString.
  4. In the app build the string before any ODBC table opens, for example GLO:ConnectionString = 'DRIVER=Sage Line 50 v15;UID=manager;PWD=xxxxxx;DIR=C:\ProgramData\Sage\Accounts\2009\Company.000\accdata'
  5. To choose the company, keep the path in an INI file with the folder number as NNN, ask the user for the company number in a window before the string is built, and replace NNN with FORMAT(number,@n03).
  6. The original poster reported it working after these steps.

Caveats

  • The poster still got a "SAGE ODBC connection" dialog to confirm at each table open; he asked for a connection-string parameter that accepts without the dialog, and the thread did not answer it.
  • The user name and password belong in your own secure storage, not in the source as in the example.

Today (2026)

Owner-name variables and DSN-less strings are likely unchanged; not re-tested, and the Sage driver name is version specific.

Sources: George B. (Mar 2010, the question and the result), Paul M., Shankar, Jean-Pierre G. (Mar 2010) in softvelocity.clarion.databasedrivers.