Overriding the /TRUSTEDCONNECTION driver option at run time before connecting to MSSQL

Applies to: the MSSQL driver; the thread names no Clarion or SQL Server version.

Problem

The poster needs to set /TRUSTEDCONNECTION according to a run-time condition (whether WebServer.IsEnabled() is TRUE or FALSE) before the application connects. SEND(MyFile, '/TRUSTEDCONNECTION=FALSE') in several embed points had no effect.

Solution

  1. Declare every SQL table in the dictionary with the driver options and the owner as global variables: DRIVER('MSSQL',GLO:DriverOptions), OWNER(GLO:MSSQL_ConnectStr).
  2. Before the first table is opened, build both strings. Base options such as /BUSYHANDLING = 2 /JOINTYPE = MSSQL /VERIFYVIASELECT = TRUE; the owner is server, database and user name separated by commas.
  3. If WebServer.IsEnabled() is FALSE, append /TRUSTEDCONNECTION = TRUE to the options. Otherwise append the password to the owner string.
  4. The original poster confirmed this technique works.

Caveats

  • SEND not working remained unexplained. One poster guessed SEND has no effect until the table is open; another answered that SEND does work on an unopened table (he used it for the TURBOSQL switch on a file that is also in the DCT).
  • A third poster asked whether a variable is used for the connection string, so that the string can be replaced conditionally.
  • Set the variables before the first open of any table.

Today (2026)

Not re-tested. Variables for the options and the owner are ordinary dictionary features and likely still work; the SEND question was not settled in the thread.

Sources: Joe (Dec 2019, the question), John S., Andrej, Geoff (Dec 2019) in softvelocity.clarion.databasedrivers.