Vbs sql help

princedx

Member
Join Date
Dec 2013
Location
HCM
Posts
49
Hi all.
I am trying to write vbs code to copy data SQL from one server to another .
i can write data to blockdata, but i cannot copy data from blockdata to WinCC.
pls show me where i wrong, thanks all




here my code :
Sub OnClick(Byval Item)

On Error Resume Next
Err.Clear

Dim conn, rst,rst1, SQL_Tabelle,Dat_Nr,Block,n,conn1,SQL_Tabelle_1
Dim DnoteNo,LogNumber,BlockNumber,ActualLength,InvoiceLength,SED,LED,Taper,Sweep,Date_T,Dnote
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
conn.Open "Provider=MSDASQL;Initial Catalog=AA;DSN=WinCC7"
conn1.Open "Provider=MSDASQL;Initial Catalog=WINCC;User ID=WINCC;Password=123456;DSN=WINCC"
Block = SmartTags("Block")
Date_T = Now()
n = 0
Dnote = SmartTags("CurrentDnote")
LogNumber = SmartTags("DnoteLogNumber")
RejectCode = SmartTags("RejectCode")
If Block >= 0 Then
BlockNumber = 1
ActualLength = SmartTags("Block1Length")
SED = SmartTags("Block1SED")
LED = SmartTags("Block1LED")
Taper = SmartTags("Block1Taper")
Sweep = SmartTags("Block1Sweep")
SQL_Tabelle = "INSERT IGNORE INTO "&"blockdata"& " VALUES ('"&Dnote &"' , '"&LogNumber &"' , '"&BlockNumber &"', '"&ActualLength &"', '"&SED&"', '"&LED &"', '"&Taper &"', '"&Sweep &"', '"&Date_T &"')"
Set rst = conn.Execute(SQL_Tabelle)
End If

MsgBox "OK"

SQL_Tabelle_1= "INSERT IGNORE INTO "&" [PTOUCH2-PC\WINCC].WINCC.dbo.WINCC " & " Select * FROM "& "blockdata"
Set rst1 = conn1.Execute(SQL_Tabelle_1)

MsgBox "COPIED"
End Sub
 

Similar Topics

hi, i am working on wincc scada & i want to read the data from sql in wincc scada.also i want to compare that data in wincc scada using vbs. can...
Replies
1
Views
5,066
Hello, I just started learning WinCC V8.0 3 days ago, so I'm still new to how everything works in this program. I've created a pop-up with a...
Replies
2
Views
693
Hello. I am trying to do some basic file operations (move file from one folder to another, rename file in the new folder etc) and usually I just...
Replies
1
Views
2,198
Hello everyone. I'm trying to export data to excel from Wincc. My code is global action that executed every second that create excel filer per...
Replies
1
Views
5,740
Hello all, I have written a VBS script to read a group of tags, and put the values and tag name etc into a text file when I press a button on one...
Replies
1
Views
1,881
Back
Top Bottom