Database Queries

Introduction

Hello and welcome to a new guide on how to best use Movicon.NExT™.

In this technote, we are going to show you how to connect to a database table and display the data within Combobox so that it can be selected and shown on screen.

Example

Movicon.NExT offers several graphical objects, and a driver, that allows you to connect to a database and perform queries.
To give you a clearer picture of how this is done we will use an example.

How to create the tag

We shall now define an Int16 type tag to connect to the PLC simulator. To do this:

Now that you have finished configuring the tag, save the project by clicking on the Save All button on the Movicon.NExT Editor’s toolbar at the top.

How to create the screen

Now, we will need to create a screen:

Once the screen has been created, you can then change the project's properties by inserting the screen as the project's Main screen which will show when the project starts up. To do this:

Once you have finished configuring the project startup page, click on the Save All icon located on the toolbar at the top to save the project.

Now, open the Main screen and click on the Toolbox tab, which is located on the far right of the editor window, next to the properties window, to open the Toolbox library provided by Movicon.NExT.
Go to the Dialog Box folder and select and drag the ComboBox object onto the screen. Select and drag the CBSelItem tag onto the object to assign it.
Now, we shall configure the data source to use with the ComboBox. In this example, we shall use the SQL Server’s Northwind sample database provided by Microsoft.
To do this:

Once the connection string has been created, you can now go ahead and connect the ComboBox to the data you wish to display. To do this:

Save the project by clicking on the Save All button on the Movicon.NExT Editor’s toolbar at the top.

Runtime Test

Now test everything in runtime mode by clicking the Start Runtime icon.
Once the screen has loaded, you should see the ComboBox showing the Eastern value on screen.
When you click on this graphical object, a list will appear with the selected column’s values. When you select one of these, the value will be obtained from the CBSelItem tag.