Dim objconnection,strsql,objcommand,strconnectionstring,objrecordset,obj
Dim e,online,ssjrksq1,ssjxfhand1
strconnectionstring="provider=msdasql;dsn=cc_zxf_05_01_04_16_15_39r;uid=;pwd=;"
Set objconnEction=CreateObject("adodb.connection")
objconnection.connectionString=strconnectionstring
objconnection.Open
Set objcOmmand=CreateObject("adodb.command")
Set obj=CreateObject("adodb.recordset")
online=HMIRuntime.Tags("online").read
ssjrksq1=HMIRuntime.Tags("ssjrksq1").read
ssjxfhand1=HMIRuntime.Tags("ssjxfhand1").read
If (online=1 And ssjrksq1=1 And ssjxfhand1=0)Then
e="select * from zymlb where fs=1 and zt=0;"
With objcommand
.activeconnEction=objconnection
.commaNdtext=e
End With
Set obj=objcommand.execute
If not obj.eof Then
obj.movefirst
HMIRuntime.Tags("ssj1xflsh").Write obj.fields(0).value
HMIRuntime.Tags("ssj1xfkou").Write obj.fields(2).value
HMIRuntime.Tags("ssj1xffs").Write obj.fields(3).value
HMIRuntime.Tags("ssj1xfpai").Write obj.fields(10).value
HMIRuntime.Tags("ssj1xflie").Write obj.fields(9).value
HMIRuntime.Tags("ssj1xfceng").Write obj.fields(8).value
End If
End If
Set objcOmmand=Nothing
objconnection.cLose
Set objconnEction=Nothing
以上这段程序是为了实现读数据库中的表,将满足条件的记录(可能是多条)的首条下发给plc。我现在的问题是当有多条记录满足时,会将满足的记录全部依次下发给plc,不知是哪里的问题?请教高手帮忙看看!