TestIT:Configuration Database connection MSSQL
6.3.2 Database connection (MSSQL)
A database connection will open a database and execute a stored procedure.
Setup fields:
- Configuration
- Connection
- Stored procedure
- Input parameters
- Output parameters & test device
Configuration:
- Write the device name and device description (required)
- Select if the device is active or not
Connection:
- Select/write the server type
- Select authentication (SQL server Authentication or Windows Authentication)
- Press Search on the databases line
- Select the database to use
- Press Connect and the control status will be shown on the left side of the connect button – Must be connected!
Stored procedure:
- Select the stored procedure name to use
- Select the timeout time in seconds. This is the max time to wait for a response from the database
- Press the Automatic button and it will generate the input parameter tab
Input parameters (a tab):
- Select the symbol to use for the device
- Press Save and it will generate the output parameters and test device.
Output parameters & test device (a tab):
- Type the input value
- Press Send and it will make a test and send it to output parameters
- Select a symbol for each received data
- Press Save and it will be possible to test more values – just type a new input value
6.3.2.1 Commands
Command in the database connection is:
Execute sample:
The stored procedure is configured like this:
| Way | Parameter | Symbol |
| Output | @parm01 | R01 |
| Output | @parm02 | R02 |
| Output | @parm03 | R03 |
| Output | @parm04 | R04 |
'Move the input parameter to the input symbol.
Misc.Move( R00,”Demo01”)
Database.Execute(MSSQLconnection,_Done)
Control is the command execute ok.
Function.If(_Done,< >,1)
'Error handling.
Function.EndIf()
'If execute ok.
'R01 values = @parm01
'R02 values = @parm02
'R03 values = @parm03
'R04 values = @parm04
6.3.2.2 SQL Data log – Example
A description of how the Database Connection (MSSWL) can be used. In the TestIT production database, we have made an area where it is possible to save 19 numbers of value and 6 of text values. Before configuring the database connection, create 19 symbols and 6 string symbols in the symbol handling.
- E.g. DS01 …… DS19 numeric symbols (double)
- E.g. DS20 …… DS25 string symbols
Instructions of how to configure the database:
- Create a database connection:
- Select Create database connection (MSSQL)
- Configuration/connection/stored procedure:
- Configuration:
- Write the device name – E.g. SQLLog
- Write a device description – E.g. Sending data to Data Log Table
- Connection:
- Write servers – E.g. (local)/sqlexpress
- Select authentication – E.g. Windows Authentication
- Press Search on the databases line
- Select the database – E.g. TestITProd
- Press Connect
- Stored procedure:
- Select the name – E.g. ISP_SQLdatalogInsert
- Press Automatic
- Configuration:
- Input parameters - Setting up TestIT symbols:
- For each parameter, select a TestIT symbol.
- Output parameters – Test
- Write an input value for each parameter
- Press Save
- Now it is possible to select a symbol
- In a TestIT program
- Create the code below and it will send all the data defined to the SQL server
' 21030 - Save to SQL
Database.Execute(SQLlog,_bool01)