发布于 2009-08-13 09:52:30
0楼
Dim connectString
Dim strsql
Dim objConnection
Dim objcommand
Dim rs
Dim DNS
Dim SERVER_ID
Dim ID
Dim THID
Dim TH_StartDate
Dim MsgNum
Dim HH_gc
Dim PZ
Dim pinzhong1
Dim pinzhong2
Dim pinzhong3
Dim pinzhong4
Dim pinzhong5
Dim HHpinzhong
Set MsgNum=HMIRuntime.Tags("MsgNum")
Set HH_gc=HMIRuntime.Tags("HH_gc")
Set THID=HMIRuntime.Tags("THID")
THID.Read
Set TH_StartDate=HMIRuntime.Tags("TH_StartDate")
TH_StartDate.Read
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set DNS=HMIRuntime.Tags("SQL_DNS")
DNS.Read
Set SERVER_ID=HMIRuntime.Tags("SQL_ID")
SERVER_ID.Read
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set pinzhong1=HMIRuntime.Tags("pinzhong1")
pinzhong1.Read
Set pinzhong2=HMIRuntime.Tags("pinzhong2")
pinzhong2.Read
Set pinzhong3=HMIRuntime.Tags("pinzhong3")
pinzhong3.Read
Set pinzhong4=HMIRuntime.Tags("pinzhong4")
pinzhong4.Read
Set pinzhong5=HMIRuntime.Tags("pinzhong5")
pinzhong5.Read
Set PZ=HMIRuntime.Tags("PZ")
PZ.Read
Set HHpinzhong=HMIRuntime.Tags("HHpinzhong")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If THID.Value=0 Then
MsgNum.Value=3
MsgNum.Write()
ExIt Sub
End if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ConnectString = "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog="&DNS.Value&";Data Source="&SERVER_ID.Value&"\WINCC"
strsql="select * from dbo.UA#LSQX order by ID desc"
Set objConnection=CreateObject("ADODB.Connection")
objConnection.ConnectionString=ConnectString
objConnection.Open
Set rs=CreateObject("ADODB.Recordset")
rs.open strsql,objConnection,3,3
Set ID=HMIRuntime.Tags("ID")
ID.Value=CStr(rs.fields(0).value)
ID.Value=ID.Value+1
ID.Write()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
strsql="Select THID from dbo.UA#LSQX where THID='"&THID.ValUe&"'"
Set objCoNnection=CreateObject("ADODB.Connection")
objConnection.ConnectiOnString=ConnectString
objConnectioN.open
Set rs=CreateObject("ADODB.Recordset")
rs.open strsql,objConnection,3,3
'MsgBox "111111111111111111",,"1111"
If rs.eoF=False Then
MsgNum.Value=1
MsgNum.Write()
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If PZ.Value=1 Then
HHpinzhong.Value=pinzhong1.Value
End If
If PZ.Value=2 Then
HHpinzhong.Value=pinzhong2.Value
End If
If PZ.Value=4 Then
HHpinzhong.Value=pinzhong3.Value
End If
If PZ.Value=8 Then
HHpinzhong.Value=pinzhong4.Value
End If
If PZ.Value=16 Then
HHpinzhong.Value=pinzhong5.Value
End If
HHpinzhong.Write()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
strsql="Insert into dbo.UA#LSQX(ID,THID,ZT,TH_StartDate,PZ) Values('"&ID.Value&"','"&THID.Value&"',1,'"&TH_StartDate.Value&"','"&HHpinzhong.Value&"')"
Set objConnection=CreateObject("ADODB.Connection")
objConnection.ConnectionString=ConnectString
objConnection.Open
Set objCommand=CreateObject("ADODB.Command")
With objCommand
.ActiveConnection=objConnectIon
.ComMandText=strsql
End With
'MsgBox "111111111111111111",,"1111"
objCommand.Execute
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'MsgBox "111111111111111111",,"1111"
HH_gc.Value=THID.Value
HH_gc.Write()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
MsgNum.Value=2
MsgNum.Write()
就是这个程序 大家有兴趣看看吧 问题出在两个MSGBOX之间那句,说不定什么时候执行不了了。他前边的语句都正常。
纯属巧合