回复:怎么样在WINCC里面用C脚本操作数据库? 怎么设置控件的一些属性?

xxyy

  • 帖子

    116
  • 精华

    2
  • 被关注

    2

论坛等级:游民

注册时间:2004-02-05

普通 普通 如何晋级?

发布于 2005-08-05 16:48:50

0楼

可以用vb脚本。有现成的例子:
1. Create the Access database with the WINCC_DATA table and (ID, TagValue) columns with the ID as the Auto Value.

2. Set up the ODBC data source with the name "SampleDSN" reference to the above Access database.

3. Programming.

Example

'VBS108

Dim objConnection

Dim strConnectionString

Dim lngValue

Dim strSQL

Dim objCommand

strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"

lngValue = HMIRuntime.Tags("Tag1").Read

strSQL = "INSERT INTO WINCC_DATA (TagValue) VALUES (" & lngValue & ");"

Set objConnection = CreateObject("ADODB.Connection")

objConnection.ConnectionString = strConnectionString

objConnection.Open

Set objCommand = CreateObject("ADODB.Command")

With objCommand

.ActiveConnection = objConnection

.CommandText = strSQL

End With

objCommand.Execute

Set objCommand = Nothing

objConnection.Close

Set objConnection = Nothing

评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32893条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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