wincc7.0通过adodb连接orcale 10,orcale的客户端已安装,建立系统NSD后,使用excel测试连接正常,在wincc中编写全局脚本,没有反应。具体代码如下,望高手能给予指点!
Dim StrConnectionString,StrSQL
Dim StrID,StrPwd,StrDBName
Dim ObjConnection
Dim Tagingvalue
Dim ObjRecordset
Dim ObjCommand
StrConnectionString = "Provider=MSDASQL;DSN=sampleDB;UID=12345;PWD=12345;"
StrSQL = "select max(t.stl_grd) from tb_ha900 t where t.lot_no like '7610553%' and t.out_dtime like '201712%';"
'--------Create Adodb Object-----------
Set ObjConnection = CreateObject("ADODB.Connection")
MsgBox ObjConnection.state
'--------Connect Database-----------
ObjConnection.connectionString = StrConnectionString
ObjConnection.Open
Set ObjRecordset = CreateObject("ADODB.Recordset")
Set ObjCommand = CreateObject("ADODB.Command")
With ObjCommand
.ActiveConnection = ObjConnection
.CommandText = StrSQL
End With
MsgBox ObjConnection.state 返回的值一直是0.