码迷,mamicode.com
首页 > 数据库 > 详细

Wincc 记录数据到sql

时间:2019-10-18 16:12:52      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:not   The   event   sql   close   call   bsp   添加   exe   

添加如下vbs脚本.

并在适当的时候调用,比如定时器触发

 

Sub LogVal(furno)
    ‘记录温度值等等  
    Dim conn ,sqlstr         
    Set conn = CreateObject("ADODB.Connection")
    conn.open  "Provider=SQLOLEDB.1;Initial Catalog=L2Share;Data Source=192.168.11.1;User ID=xcg;Password=123456;"        
    
    If(furno =1) Then     Call LogValF1(conn,furno)     End If
    If(furno =2) Then     Call LogValF2(conn,furno)     End If
    
    conn.close        ‘关闭连接
    Set conn=Nothing        ‘释放对象
    
End Sub

Sub LogValF1(conn,furno)
    ‘F1记录温度值等等  
    Dim sqlstr         
    Dim ValuesList
    Dim t1,s1,s2,s3
    Dim v0,v1,v2,v3,v4,v5,v6,v7
    t1= ",‘"&Now()&"‘"
    ‘‘‘ t1= "‘" & Year(Now)&"-"&Month(Now)&"-"&Day(Now)&" "&  Hour(Now)&":"&Minute(Now)&":"&Second(Now)& "‘"
    
    v0=",100"
    v1=",101"
    ValuesList =furno &t1 &v0 &v1
    sqlstr=  "Insert Into 退火炉采集值表 (炉号,时间,V0,V1) Values("& ValuesList &")"
    conn.Execute(sqlstr)   
End Sub

Sub LogValF2(conn,furno)
    ‘F2记录温度值等等  
    Dim sqlstr   
    Dim ValuesList
    Dim t1,s1,s2,s3
    Dim v0,v1,v2,v3,v4,v5,v6,v7
    t1= ",‘"&Now()&"‘"
    ‘‘‘ t1= "‘" & Year(Now)&"-"&Month(Now)&"-"&Day(Now)&" "&  Hour(Now)&":"&Minute(Now)&":"&Second(Now)& "‘"
    
    v0=",200"
    v1=",201"
    ValuesList = furno &t1 &v0 &v1
    sqlstr=  "Insert Into 退火炉采集值表 (炉号,时间,V0,V1) Values("& ValuesList &")"
    conn.Execute(sqlstr)   
End Sub

Sub LogEvent(furno,planid,e)
    ‘记录事件名等等  
    Dim conn ,sqlstr         
    Set conn = CreateObject("ADODB.Connection")
    conn.open  "Provider=SQLOLEDB.1;Initial Catalog=L2Share;Data Source=192.168.11.1;User ID=xcg;Password=123456;"        
    Dim t1,t2
    Dim ValuesList
    t1="‘"&Date()&"‘"
    t2="‘"&Now()&"‘"
    ValuesList =t1 &","&t2 &","&furno&",‘" &planid &"‘,‘" &e&"‘"
    sqlstr=  "Insert Into 退火炉事件表 (日期,时间,炉号,生产计划号,事件名) Values("&ValuesList&")"
    conn.Execute(sqlstr)    
    conn.close        ‘关闭连接
    Set conn=Nothing        ‘释放对象
End Sub 

Wincc 记录数据到sql

标签:not   The   event   sql   close   call   bsp   添加   exe   

原文地址:https://www.cnblogs.com/NianJiTao/p/11698384.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!