现在想用WinCC和Oracle数据库连接通信。连接已经没有问题,简单的读写也没有问题。
我得代码如下:
strConnectionString = "DRIVER={Oracle ODBC Driver};UID=Sys;PWD=Sys;DBQ=Sys;"
strSQL = "select name from stu where ID = 1;"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.connectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
Set objRecordset = objCommand.Execute
lngCount = objRecordset.Fields.Count
If (lngCount>0) Then
objRecordset.movefirst
lngValue = objRecordset.Fields(0).Value
HMIRuntime.Tags("dbValue").Write lngValue
…