1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > wincc通过vb如何读取mysql_wincc如何通过VB脚本读取报警数据库归档内容-工业支持中心-

wincc通过vb如何读取mysql_wincc如何通过VB脚本读取报警数据库归档内容-工业支持中心-

时间:2024-01-14 08:07:44

相关推荐

wincc通过vb如何读取mysql_wincc如何通过VB脚本读取报警数据库归档内容-工业支持中心-

刚接触wincc,下面脚本是根据帮助文档VB实例修改,但读取不到归档内容,系统内置报警控件中能读到数据,请大神指点。

'1.1CreateconnectionstringforADOaccess

DimProviderName

DimCatalogName

DimDataSourceName

DimConnectionString

DimCommandString

Dimsnam1,Rtname

DimServerName1

SetServerName1=HMIRuntime.Tags("@ServerName")

ServerName1.Read

DimDatasourceNameRT

SetDatasourceNameRT=HMIRuntime.Tags("@DatasourceNameRT")

DatasourceNameRT.Read

Rtname=DatasourceNameRT.Value

snam1=ServerName1.Value

ConnectionString="provider=WinCCOLEDBProvider.1;catalog="&Rtname&";datasource="&snam1&"\WinCC"

'1.2Definecommandstringforaccess(relativetimerange,last10minutes)

CommandString="ALARMVIEW:Select*fromalgviewchtWHEREDateTime>'-11-3000:00:00.000'"

DimDBConnection

DimDBCommand

DimDBRecordset

'2.1Openconnection

'HMIRuntime.Trace"beforeopenconnection"&vbNewLine

SetDBConnection=CreateObject("ADODB.Connection")

DBConnection.ConnectionString=ConnectionString

DBConnection.CursorLocation=3

DBConnection.open

SetDBRecordset=CreateObject("ADODB.Recordset")

'2.2Executecommand

'HMIRuntime.Trace"beforeexecutecommand"&vbNewLine

SetDBCommand=CreateObject("mand")

mandType=1

DBCommand.ActiveConnection=DBConnection

mandText=CommandString

SetDBRecordset=DBCommand.Execute

DimlngCount

DimlngValue,aa

'2.3Recordstructureandfirstrecorddata(test)

lngCount=DBRecordset.Fields.Count

aa=DBRecordset.RecordCount

HMIRuntime.Trace"RecordSet.Field.Count="&lngCount&vbNewLine

HMIRuntime.Trace"RecordSet.RecordCount="&aa&vbNewLine

If(aa>0)Then

DBRecordset.movefirst

Else

HMIRuntime.Trace"Selectionreturnednofields"&vbNewLine

EndIf

'4.1Cleanup

DBRecordset.Close

SetDBRecordset=Nothing

SetDBCommand=Nothing

DBConnection.Close

SetDBConnection=Nothing

HMIRuntime.Trace"Connectionclosedagain"&vbNewLine

问题补充:

数据库已经连接上,脚本调试输出如图,显示库中无数据。

图片说明:

悬赏西币:5 | 解决时间:-12-07 09:46:25 | 提问者:SHUREN2 - 新生&nbsp&nbsp第1级

问题ID:179378

wincc通过vb如何读取mysql_wincc如何通过VB脚本读取报警数据库归档内容-工业支持中心-西门子中国...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。