我打开wincc自带的SQL,在数据库“CC_AronBlow_13_09_13_10_20_16R”下新建了一个TABLE(不知道合不合理),然后想通过wincc组态达到内部变量与这个表中的数据交换的目的(读和写)
现在我建了11个内部变量,并分别与11个I/O与连接向内部变量写数据,然后通过一个按钮将变量内的数据写入这个TABLE下,但始终为把数据写入表中,请问大神问题出在哪?按钮代码如下:
Dim objConnection
Dim objCommand
Dim objRecordset
Dim strConnectionString
Dim strSQL
Dim STEELNAME,F1,T1,F2,T2,F3,T3,F4,T4,F5,T5
STEELNAME=HMIRuntime.Tags("钢种").Read
F1=HMIRuntime.Tags("流量1").Read
F2=HMIRuntime.Tags("流量2").Read
F3=HMIRuntime.Tags("流量3").Read
F4=HMIRuntime.Tags("流量4").Read
F5=HMIRuntime.Tags("流量5").Read
T1=HMIRuntime.Tags("时间1").Read
T2=HMIRuntime.Tags("时间2").Read
T3=HMIRuntime.Tags("时间3").Read
T4=HMIRuntime.Tags("时间4").Read
T5=HMIRuntime.Tags("时间5").Read
strConnectionString = "DRIVER={SQL server};SERVER=.\WinCC;DATABASE=CC_AronBlow_13_09_13_10_20_16R;UID=;PWD="
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
strSQL = "insert into STEELSERIES (STEEL,F1,T1,F2,T2,F3,T3,F4,T4,F5,T5)values ('"&STEELNAME&"',"&F1&","&T1&","&F2&","&T2&","&F3&","&T3&","&F4&","&T4&","&F5&","&T5&");"
MsgBox(strSQL)
objCommand.CommandText = strSQL
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objRecordset = Nothing
Set objConnection = Nothing