Option Explicit
Function action
Dim BS201
Dim BS202
Dim BS200
Dim RM_MASTER '判断是否执行全局脚本
Set RM_MASTER = HMIRuntime.Tags("A33")
RM_MASTER.Read
If RM_MASTER.Value = 1 Then
Set BS201 = HMIRuntime.Tags("ChannelOut1")
BS201.Read()
Set BS202 = HMIRuntime.Tags("ChannelOut4")
BS202.Read()
BS200 = BS201.Value + BS202.Value
'//DATABASE
Dim objAdoConn
Dim objRecordset
Dim objCommand
Dim strAdoConn
Dim strSQL
Dim retVal
Dim FrontstrSQL
Dim BackstrSQL
Dim BSstrSQL
Set objAdoConn= CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
Set strAdoConn = HMIRuntime.Tags("ADOConnectStr")
strAdoConn.Read()
objAdoConn.CommandTimeout=5
objAdoConn.connectionstring = strAdoConn.Value
objAdoConn.CursorLocation = 3'//important
objAdoConn.open
BSstrSQL ="insert into BSData(RecordTime,BS201,BS202,BS200,TimePointStr"&_
")values"&_
"('"&Now()&"','"&BS201.value&"','"&BS202.value&"','"&BS200&"',0,'00:00')"
objAdoConn.Execute FrontstrSQL
objAdoConn.Execute BackstrSQL
objAdoConn.Execute BSstrSQL
If Err.Number<>0 Then
MsgBox Err.Description
Err.Clear
End If
objRecordset.close
Set objRecordset = Nothing
Set objCommand = Nothing
objAdoConn.close
Set objConnection = Nothing
'RM_MASTER.Value = 0
Set M_MASTER.Value = HMIRuntime.Tags("A33")
'1#通道报警处理
'(LLA)
'If objtag2.Value
tag1.Value = 0
tag1.Write 'statements
End If
我用的是SQL2008R2,因是初次使用VBS脚本配合wincc,上面是我写的数据写入数据库脚本,可是SQL内部没有我写的数据,是不是缺少创建数据库脚本,有没有详细一点的操作步骤,SQL需不需要设置?
悬赏西币:5 | 解决时间:2018-08-24 20:48:02 | 提问者: 20160427NL8TB2 - 新生  第1级
问题ID:197860