Binding The SQL Query Datasource

Ignition 7.1.4 comes with the new SQL Query datasource binding feature.

This new feature makes SQL Query bindings more flexible about which datasources are used.

For example if you had a group of windows for user administration and security and you decided to use a different database for this data than is used by the default datasource, you could bind the SQL queries of these windows to a client tag that names the new datasource. Later on if you wanted to use these same windows for a different project that uses a different datasource, changing the name of the datasource in the client tag would change the datasource for all these windows.

Simply put, binding SQL Query datasources to a client tag allows datasource configuration for a group of windows in one spot.

This makes windows more reusable. Without this feature the datasource used by a group of windows is fixed, which means the windows are hard to reuse in other projects if you don’t want them to use the default datasource. You would have to change every SQL Query binding in every window to the new datasource by hand.

We used this feature to implement live and training databases on one of our data collection systems. New users are put into a Training group which only gives them access to the training database, indicated by a flag at the top of the screen. Once they are trained an Administrator removes them from the Training group and when they next log in they get access to the live system. This is implemented by a start-up script which checks whether a user is a member of the Training group and writes the name of the appropriate database into a Client tag. This client tag is then used in the datasource binding.

The customer has really appreciated this functionality while training new users.

Wow thats an awesome idea.

I realize this is a really old thread. This is a great idea and exactly what I want to do. But in my Table Component under the binding for the Data property, I have a query that works. Now I want to dynamically choose a different “Database Connection” in the future. There are property and tag selectors next to the Database Connection, but when I choose a client tag (string type), it just turns red like it does not like that. The query still works unless I change the value of the string tag, but why does it change the text to red as though something is wrong with it?

Well, that was an interesting rabbit hole. I can see where in the code we’re setting it to red, and it’s very much an intentional change, just indicating that you’ve got a binding. I don’t know why we chose red for that (a decade ago), but, that’s what was selected :man_shrugging:

I don’t think that it’s meant to indicate any kind of problem - at most, I would say it’s an indication “be aware that this query could break unexpectedly as a result of the datasource changing”.

thanks, It kind of freaked me out at first, but I noticed the Table wasn’t crying about it. Then i changed the client tag string to something invalid and the table then showed it was definitely broken. Red is definitely an odd choice.