quote:以下是引用bcap在2009-03-05 15:25:22的发言:
赞助一下!
呵呵 供参考!
把tag1的数据写入数据库的mytable表中!
Dim objConnection
Dim strConnectionString
Dim lngValue
Dim strSQL
Dim objCommand
strConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=SKY\WINCC"
lngValue = HMIRuntime.Tags("tag1").Read
strSQL = "INSERT INTO mytable (Taga) VALUES (" & lngValue & ");"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing