项目在WINCC6.0里写SQL2000没问题,但到了WINCC6.2后怎么也写不进SQL2005了,那位高人帮忙分析下(以下是脚本程序):
Option Explicit
Function action
Dim objConnection
Dim strConnectionString
Dim AA1,AA2,AA3,AA4,AA5
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=abc;DATABASE=sql_report;UID=sa;PWD=000000;"
AA1 = HMIRuntime.Tags("a1").Read
AA2 = HMIRuntime.Tags("a2").Read
AA3 = HMIRuntime.Tags("a3").Read
AA4 = HMIRuntime.Tags("a4").Read
AA5 = HMIRuntime.Tags("a5").Read
strSQL = "INSERT INTO sql_test (dt,a1,a2,a3,a4,a5) VALUES ('"&Now()&"','" & AA1 & "','" & AA2 & "','" & AA3 & "','" & AA4 & "','" & AA5 & "');"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
End Function
相应的数据库表格都已建好,ODBC连接都测试正常