Guten Tag,
Nicht wundern SMARTTAGS sind Variablen aus einer SPS.
Wenn ich das Script so ausführe kommt folgenden Fehlermeldung: "Command Text was not set for Command Object"
Wenn ich allerdings alle Variablen (V1-V33) mit richtigen Werten fütttere z.b. V1 = "1" dann läuft das Script ohne Probleme.
Hat jemand einen Lösungsvorschlag dafür?
Nicht wundern SMARTTAGS sind Variablen aus einer SPS.
Wenn ich das Script so ausführe kommt folgenden Fehlermeldung: "Command Text was not set for Command Object"
Wenn ich allerdings alle Variablen (V1-V33) mit richtigen Werten fütttere z.b. V1 = "1" dann läuft das Script ohne Probleme.
Hat jemand einen Lösungsvorschlag dafür?
Code:
Dim conn, rst, dbname, tblname Dim SQL_Table1, SQL_Table2, SQL_Table3, SQL_Table4, SQL_Table5, SQL_Table6, SQL_Table7 Dim dbpath Dim V1, V2, V3, V4, V5, V6, V7, V8, V9, V10 Dim V11, V12, V13, V14, V15, V16, V17, V18, V19, V20 Dim V21, V22, V23, V24, V25, V26, V27, V28, V29, v30, v31, v32, v33 On Error Resume Next Err.Clear 'Mainloop V1 = Date & " "& "00:00:00" 'Today 00:00:00 V2 = SmartTags("SQL\WFI\Statistik.MaxVal[2]") '5220TE400_Max V3 = SmartTags("SQL\WFI\Statistik.MinVal[2]") '5220TE400_Min V4 = SmartTags("SQL\WFI\Statistik.MaxVal[5]") '5220PT400_Max V5 = SmartTags("SQL\WFI\Statistik.MinVal[5]") '5220PT400_Min V6 = SmartTags("SQL\WFI\Statistik.MaxVal[3]") '5220TE401_Max V7 = SmartTags("SQL\WFI\Statistik.MinVal[3]") '5220TE401_Min V8 = SmartTags("SQL\WFI\Statistik.MaxVal[6]") '5220CE400_Max V9 = SmartTags("SQL\WFI\Statistik.MinVal[6]") '5220CE400_Min V10 = SmartTags("SQL\WFI\Statistik.MaxVal[7]") '5220AT400_Max V11 = SmartTags("SQL\WFI\Statistik.MinVal[7]") '5220AT400_Min V12 = SmartTags("SQL\WFI\Statistik.MaxVal[8]") '5220TE404_Max V13 = SmartTags("SQL\WFI\Statistik.MinVal[8]") '5220TE404_Min V14 = SmartTags("SQL\WFI\Statistik.MaxVal[11]")'5240TE403_Max V15 = SmartTags("SQL\WFI\Statistik.MinVal[11]")'5240TE403_Min 'Subloop V16 = SmartTags("SQL\WFI\Statistik.MaxVal[19]") '5240PT400_Max V17 = SmartTags("SQL\WFI\Statistik.MinVal[19]") '5240PT400_Min V18 = SmartTags("SQL\WFI\Statistik.MaxVal[21]") '5240CE400_Max V19 = SmartTags("SQL\WFI\Statistik.MinVal[21]") '5240CE400_Min V20 = SmartTags("SQL\WFI\Statistik.MaxVal[22]") '5240AT400_Max V21 = SmartTags("SQL\WFI\Statistik.MinVal[21]") '5240AT400_Min V22 = SmartTags("SQL\WFI\Statistik.MaxVal[21]") '5240TE404_Max V23 = SmartTags("SQL\WFI\Statistik.MinVal[21]") '5240TE404_Min V24 = SmartTags("SQL\WFI\Statistik.MaxVal[23]") '5220TE403_Max V25 = SmartTags("SQL\WFI\Statistik.MinVal[23]") '5220TE403_Min 'PS distribution V26 = SmartTags("SQL\WFI\Statistik.MaxVal[26]") '5320PT501_Max V27 = SmartTags("SQL\WFI\Statistik.MinVal[26]") '5320PT501_Min V28 = SmartTags("SQL\WFI\Statistik.MaxVal[25]") '5320TE500_Max V29 = SmartTags("SQL\WFI\Statistik.MinVal[25]") '5320TE500_Min v30 = SmartTags("SQL\WFI\Statistik.MaxVal[27]") '5320CE501_Max v31 = SmartTags("SQL\WFI\Statistik.MinVal[27]") '5320CE501_Min v32 = SmartTags("SQL\WFI\Statistik.MaxVal[28]") '5320TT501_Max v33 = SmartTags("SQL\WFI\Statistik.MinVal[28]") '5320TT501_Min Set conn = CreateObject("ADODB.Connection") Set rst = CreateObject("ADODB.Recordset") dbname = "WFI_Parameter" tblname = "Max_Min" dbpath = "[" & dbname & "].dbo." & tblname '--------------------------------------- 'Open data source - Datenquelle öffnen conn.Open "Provider=MSDASQL;DSN=WinCCFlex_to_SQL" '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table1 = "INSERT INTO " & dbpath & " ([Timestamp],[5220TE400_Max],[5220TE400_Min],[5220PT400_Max],[5220PT400_Min]) VALUES ('" & V1 & "' , '" & V2 & "' , '" & V3 & "' , '" & V4 & "', '" & V5 & "')" 'Writes a data record into a table Set rst = conn.Execute(SQL_Table1) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table2 = "UPDATE " & dbpath & " Set " & "[5220TE401_Max]" & " = " & V6 & " , " & "[5220TE401_Min]" & " = " & V7 & " , " & "[5220CE400_Max]" & " = " & V8 & " , " & "[5220CE400_Min]" & " = " & V9 & " , " & "[5220AT400_Max]" & " = " & V10 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table2) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table3 = "UPDATE " & dbpath & " Set " & "[5220AT400_Min]" & " = " & V11 & " , " & "[5220TE404_Max]" & " = " & V12 & " , " & "[5220TE404_Min]" & " = " & V13 & " , " & "[5240TE403_Max]" & " = " & V14 & " , " & "[5240TE403_Min]" & " = " & V15 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table3) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table4 = "UPDATE " & dbpath & " Set " & "[5240PT400_Max]" & " = " & V16 & " , " & "[5240PT400_Min]" & " = " & V17 & " , " & "[5240CE400_Max]" & " = " & V18 & " , " & "[5240CE400_Min]" & " = " & V19 & " , " & "[5240AT400_Max]" & " = " & V20 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table4) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table5 = "UPDATE " & dbpath & " Set " & "[5240AT400_Min]" & " = " & V21 & " , " & "[5240TE404_Max]" & " = " & V22 & " , " & "[5240TE404_Min]" & " = " & V23 & "," & "[5220TE403_Max]" & " = " & V24 & " ," & "[5220TE403_Min]" & " = " & V25 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table5) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table6 = "UPDATE " & dbpath & " Set " & "[5320PT501_Max]" & " = " & V26 & " , " & "[5320PT501_Min]" & " = " & V27 & " , " & "[5320TE500_Max]" & " = " & V28 & "," & "[5320TE500_Min]" & " = " & V29 & " ," & "[5320CE501_Max]" & " = " & v30 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table6) '--------------------------------------- 'Select data record of the table - Datensatz der Tabelle auswählen SQL_Table7 = "UPDATE " & dbpath & " Set " & "[5320CE501_Min]" & " = " & v31 & " , " & "[5320TT501_Max]" & " = " & v32 & " , " & "[5320TT501_Min]" & " = " & v33 & " WHERE [5220TE400_Max] = " & V2 'Writes a data record into a table Set rst = conn.Execute(SQL_Table7) '--------------------------------------- 'Close data source - Datenquelle schließen conn.close SmartTags("boIs24hOver") = True ' Copy DB161(Calculating Max/Min) to DB160(CRXIX) + Reset DB161 If Err.Number <> 0 Then ShowSystemAlarm "SQL_WFI_Max_Min Error Code: " & Err.Number & " / Error Description: " & Err.Description End If Set rst = Nothing Set conn = Nothing