sql server - How to use tags in Simatic WinCC Flexible VB script -
i trying insert wincc tags value sql server. firstly defined sql connection , i've tested inserting rough values simple sql tag like:
strsql = "insert test (t1,t2) values (3,4)"
i saw can use variables in sql cmd
const d = 5 strsql = "insert test (t1,t2) values (" & d & ",4)"
how should use wincc tags instead of variable?
i can share code used wincc flexible 2008 insert database simple record afeter recipe finished plant.
'------------------------------------------------------------ dim sserver,sdatabasename ,sconn,oconn,ors, fetchdata dim susername,spassword dim adopenkeyset, adlockoptimistic, adcmdtable dim mrecordstr, tablename dim field dim loc_pressure dim loc_enddatetime dim loc_receipe dim loc_begindatetime dim loc_user dim loc_temperature loc_user = smarttags("databasesql\var_user") loc_begindatetime = cdate(smarttags("databasesql\var_begindatetime")) loc_enddatetime = cdate(smarttags("databasesql\var_enddatetime")) loc_receipe = smarttags("databasesql\var_receipe") loc_pressure = smarttags("databasesql\var_pressure") loc_temperature = smarttags("databasesql\var_temperature") sserver = "192.168.40.3" 'e.g sdatabasename = "dbplc" susername = "user"'insert user name enabled in database spassword = "secretpassword" ' tablename = "table_plc" adopenkeyset = 1 adlockoptimistic = 3 adcmdtable = 2 sconn="driver={sql server};server=" & sserver & ";database=" & sdatabasename & ";encrypt=no;" set oconn = createobject("adodb.connection") oconn.commandtimeout = 36000 oconn.open sconn, susername, spassword set fetchdata = createobject("adodb.recordset") 'fetchdata.open "select * table_plc", oconn, 3 fetchdata.open tablename, oconn, adopenkeyset, adlockoptimistic, adcmdtable fetchdata.addnew fetchdata.fields("user").value = loc_user fetchdata.fields("begindatetime").value = loc_begindatetime fetchdata.fields("enddatetime").value = loc_enddatetime fetchdata.fields("receipe").value = loc_receipe fetchdata.fields("pressure").value = loc_pressure fetchdata.fields("temperature").value = loc_temperature fetchdata.update fetchdata.close oconn.close