SQL Database Using VBScripts
SQL Database Using VBScripts
SQL Database Using VBScripts
conn.Open "Provider=MSDASQL;DSN="&Database_Name&""
SQL_Table = "CREATE DATABASE " & SmartTags("database") SQL is an acronym that stands for Structured Query Language. SQL is a programming language designed for managing data
in relational database management systems. Since its initial development, SQL has continued to grow in popularity and is
Set rst = conn.Execute(SQL_Table) the most widely used database language in the world
conn.close There are different database server available to store and create relational database one of which is Microsoft SQL Server
which is very popular and easy to use. Sql language can be further used to run queries
Set conn = Nothing
Set rst = Nothing Scripting in HMI/SCADA is used to provide customization such as reading tags, linking databases,
VBS (Visual Basic Script) is a scripting language developed by Microsoft. It is closely related to VB (Visual Basic) and VBA
End Sub (Visual Basic for Applications). VBS is used in WinCC to dynamize the graphical objects in process operation (Runtime):
• Tags Tag values can be read and written, e.g. to specify tag values for the controller via a mouse click event on a button.
• Objects Object properties can be made dynamic using actions, and actions can be triggered by events influencing objects.
• Screen-independent actions Screen-independent actions can be triggered cyclically or according to tag values, e.g. for the
daily transfer of values into an Excel table.
Time Series Database can also be created using SQL Database for which expensive historians are used however that also
includes some additional features such as analytics.
SQL_Table = "CREATE TABLE "& SmartTags("tablename") & " (Nr SMALLINT, " _
& SmartTags("col_1") & " CHAR(30), " & SmartTags("col_2") & " SMALLINT, " _
& SmartTags("col_3") & " SMALLINT)"
conn.close
End Sub
SQL_Table = "SELECT * FROM " & SmartTags("tablename") & " WHERE Nr = " & SmartTags("nDat_No")
SQL_Table = "INSERT INTO "& SmartTags("tablename") & " VALUES ('" & SmartTags("nDat_No") &
_
"' , '" & SmartTags("val1") & "' , '" & SmartTags("val2") & _
"' , '" & SmartTags("val3") & "')"
conn.close
Main Page 1
SQL_Table = "SELECT * FROM " & SmartTags("tablename") & " WHERE Nr = " & SmartTags("s_no")
SmartTags("s_no") = rst.Fields(0).Value
SmartTags("val1") = rst.Fields(1).Value
SmartTags("val2") = rst.Fields(2).Value
SmartTags("val3") = rst.Fields(3).Value
SmartTags("col1") = rst.Fields(1).Name
SmartTags("col2") = rst.Fields(2).Name
SmartTags("col3") = rst.Fields(3).Name
rst.close
conn.close
End Sub
Main Page 2