Wincc报警记录的相关操作SQL
侧边栏壁纸
  • 累计撰写 20 篇文章
  • 累计收到 3 条评论

Wincc报警记录的相关操作SQL

滕招
2021-10-21 / 0 评论 / 954 阅读 / 正在检测是否收录...

Dim DNRT,DSN
Dim con,conn,oRs,oCom,sSQL
Dim con1,conn1,oRs1,oCom1,sSQL1
Dim BH
Dim rc
Dim i
DNRT = HMIRuntime.Tags("@DatasourceNameRT").Read
BH = ScreenItems("bianhao").InputValue

    con=  "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog="&DNRT&";Data Source=.\wincc"
    Set conn= CreateObject("ADODB.Connection") 
    conn.ConnectionString=con 
    conn.CursorLocation=3
    conn.Open

    Set oRs=CreateObject("ADODB.Recordset")                                                
    Set oCom= CreateObject("ADODB.Command") 
    Set oCom.ActiveConnection=conn
    oCom.CommandType=1
    
sSQL="SELECT DSN FROM AMT WHERE AppName='ALG' "
oCom.CommandText=sSQL
Set oRS=oCom.Execute
rc=oRS.RecordCount

oRS.movefirst
For i = 1 To rc
DSN=oRs.fields(0).Value

    con1=  "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog="&DSN&";Data Source=.\wincc"
    Set conn1= CreateObject("ADODB.Connection") 
    conn1.ConnectionString=con1
    conn1.CursorLocation=3
    conn1.Open

    Set oRs1=CreateObject("ADODB.Recordset")                                                
    Set oCom1= CreateObject("ADODB.Command") 
    Set oCom1.ActiveConnection=conn1
    oCom1.CommandType=1
    
sSQL1="DELETE FROM [MsArcLong] WHERE MsgNr = "&BH
oCom1.CommandText=sSQL1
Set oRS1=oCom1.Execute
Set oRS1=Nothing  
oRS.movenext
Next
Set oRS=oCom.Execute
Set oRS=Nothing 
conn.close
Set conn=Nothing
conn1.close
Set conn1=Nothing

Msgbox("对应编号报警已经删除,重新打开此画面查看。")
2

评论 (0)

取消