This script is useful in datalogging purpose. This script is common for Wincc Advanced, Wincc Professional. For Wincc 7.x the tag declaration will change
Dim objConnection
Dim strConnectionString
Dim FieldName
Dim Record
Dim strSQL
Dim objCommand
Dim strfile
strfile = "C:\Reports\Database.mdb"
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strfile & ";"
strSQL = "INSERT INTO TableName (" & FieldName & ") VALUES (" & Record & ");"
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
Dim objConnection
Dim strConnectionString
Dim FieldName
Dim Record
Dim strSQL
Dim objCommand
Dim strfile
strfile = "C:\Reports\Database.mdb"
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strfile & ";"
strSQL = "INSERT INTO TableName (" & FieldName & ") VALUES (" & Record & ");"
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
No comments:
Post a Comment