WINCC与SQL数据库写不尽数据

已锁定

星空366

西门子1847工业学习平台

  • 帖子

    18
  • 精华

    0
  • 被关注

    24

论坛等级:游士

注册时间:2016-07-12

黄金 黄金 如何晋级?

WINCC与SQL数据库写不尽数据

839

6

2024-05-24 08:54:30

最近刚刚接触WINCC 跟着网上教学 做的,现在 WINCC控制PLC正常 就是往数据库写数据时报错,我也搞不定是配置数据库问题,还是代码问题,大佬帮忙看看 !


Option Explicit

Function action

Dim Number,StartTime,StopTime,RunTime

Dim rep

rep=HMIRuntime.Tags("SQL_Pump1_Rep").Read

If rep=1 Then

Number="1#水泵"

StartTime=HMIRuntime.Tags("SQL_Pump1_StartTime").Read

StopTime=HMIRuntime.Tags("SQL_Pump1_StopTime").Read

RunTime=HMIRuntime.Tags("SQL_Pump1_Running").Read

Dim sCon,conn,oRs,sSql,oCom

sCon="SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=wang;Initial Catalog=pump;Data Source=BXDPC\WINCC"

sSql="insert into BB1(编号,启动时间,停止时间,运行时间)values('"&Number&"','"&StartTime&"','"&StopTime&"','"&RunTime&"');"

Set conn=Createobject("ADODB.Connection")

conn.ConnectionString=sCon

conn.Cursorlocation=3

conn.open

Set oRs = CreateObject("ADODB.Recordset")

Set oCom=CreateObject("ADODB.Command")

oCom.commandType=1

Set oCom.ActiveConnection=conn

oCom.CommandText=sSql

Set oRs =oCom.execute

conn.close

Set oCom = Nothing

Set oRs = Nothing

Set conn=Nothing

End If 

End Function


WINCC与SQL数据库写不尽数据 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32581条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。