Switching default database in named queries

I'm developing an application to retrieve data from an SQL Express server running on the machine's HMI. I have some of the named queries operational at this stage.1

I have a second identical machine running its own instance of SQL Express and will set up a separate database connection for it.

Question: what is the smart way to switch database connections (or switch the application's default database) when using named queries? (Any Perspective client will be looking at one machine or the other with selection by user.)


1 Old SQL server driver / connection setup here:

The only way that I know of is to use the database parameter. I don't rely on default project settings for databases (or tag providers).

  1. Providing a these by parameter makes the call explicit and more readable for future programmers.
  2. I work in an environment where someone other than me may change the project defaults, so this ensures my code doesn't break.
1 Like

Duh! There's a parameter option in the Database Connection dropdown! I've been doing this for years and never noticed (but hadn't needed to).

https://docs.inductiveautomation.com/display/DOC81/Named+Query+Workspace#NamedQueryWorkspace-Authoring

Thanks.

1 Like