按wincc的查询格式查询不到数据

已锁定

null

  • 帖子

    58
  • 精华

    0
  • 被关注

    2

论坛等级:游民

注册时间:2008-07-26

普通 普通 如何晋级?

按wincc的查询格式查询不到数据

1544

7

2009-01-07 09:46:52

我的代码如下:主要完成的功能是:要在画面中获得归档数据库中的数据,一共有四个I/O域,1号用于输入开始查询的时间,2号用于输入查询结束的时间,3号用于输入归档周期,这三个I/O域的输入格式都要参考wincc6.0专用归档命令所要求格式,4号用于输出查询结果.
Dim starttime
Dim endtime
Dim periodtime
Dim ConnectionObj
Dim Connectionstring
Dim CommandStr_TimeStart
Dim CommandStr_TimeEnd
Dim CommandObj
Dim RecordSetObj
Dim count
Dim resultt
Dim temp1
Dim temp2

starttime=HMIRuntime.Tags("TimeStart").Read
endtime=HMIRuntime.Tags("TimeEnd").Read
periodtime=HMIRuntime.Tags("TimePeriod").Read
HMIRuntime.Tags("Result").Write 0
'a=ScreenItems("shurushuchuyu1").OutputValue
'b=ScreenItems("shurushuchuyu2").OutputValue
'c=ScreenItems("shurushuchuyu3").OutputValue

Connectionstring="Provider=WinCCOLEDBProvider.1;Catalog=CC_sdsd_09_01_05_09_38_35R;Data

Source=.\WinCC"
CommandStr_TimeStart="Tag:R,'ProcessValueArchive\NewTag',0000-00-00 00:01:00.000','0000-00-

00 00:00:00.000'"
'CommandStr_TimeStart=CommandStr_TimeStart+"'"+starttime+"'"+","+"'0000-00-00 00:01:00.000'"
'CommandStr_TimeEnd="Tag:R,'ProcessValueArchive\NewTag',"'....'0000-00-00

00:01:00.000','0000-00-00 00:00:00.000'
'CommandStr_TimeEnd=CommandStr_TimeEnd+"'"+endtime+"'"+","+"'0000-00-00 00:01:00.000'"
MsgBox CommandStr_TimeStart
MsgBox CommandStr_TimeEnd
Set ConnectionObj=CreateObject("ADODB.Connection")
ConnectionObj.ConnectionString=Connectionstring
ConnectionObj.CursorLocation=3
ConnectionObj.Open
MsgBox Connectionstring

Set RecordSetObj=CreateObject("ADODB.Recordset")
Set CommandObj=CreateObject("ADODB.Command")

Set CommandObj.ActiveConnection=ConnectionObj
CommandObj.CommandType=1

CommandObj.CommandText=CommandStr_TimeStart
Set RecordSetObj=CommandObj.Execute
MsgBox "command...executing....1111"
temp1=RecordSetObj.Fields(2).Value
MsgBox "command...executed...1111"

'CommandObj.CommandText=CommandStr_TimeEnd
'Set RecordSetObj=CommandObj.Execute
'MsgBox "command...executing...2222"
'temp2=RecordSetObj.Fields(2).Value
'MsgBox "command...executed...2222"

count=RecordSetObj.Fields.Count
'MsgBox RecordSetObj.Fields(count).Name
MsgBox RecordSetObj.Fields(count-1).Name
MsgBox RecordSetObj.Fields(count-2).Name
MsgBox RecordSetObj.Fields(count-3).Name
MsgBox RecordSetObj.Fields(count-4).Name
MsgBox RecordSetObj.Fields(count-5).Name

MsgBox count,,"fields-count"
resultt=temp1-temp2
HMIRuntime.Tags("Result").Write resultt
MsgBox resultt
RecordSetObj.Close

Set RecordSetObj=Nothing
Set CommandObj=Nothing
ConnectionObj.Close
Set ConnectionObj=Nothing
按照这句查的时候: CommandStr_TimeStart="Tag:R,'ProcessValueArchive\NewTag',0000-00-00

00:01:00.000','0000-00-00 00:00:00.000'"
是可以查询出结果的,把0000-00-00 00:01:00.000改为0000-00-00 00:30:00.00也是可以查出结果的,但

只要把查询语句里的两个时间值改成一个时间值 ,比如2009-01-07 08:00:00.000,或者两都都改变,就查

不到数据了,测试的时候,错误的原因是因为返回的数据集为空,即EOF,不知道怎么原因,能否请大侠指点一

下!!!!!
按wincc的查询格式查询不到数据 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32940条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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