SQL: Read value from Table



0
447

-Code VB Script - WinCC Advanced (WinCC Prof. : SmartTags("")= HMIRuntime.Tags("").Read) ********************* Sub N04_Read_a_value(ByRef DSN_NAME) Dim conn, rst, SQL_Table On Error Resume Next Set conn = CreateObject("ADODB.Connection") Set rst = CreateObject("ADODB.Recordset") 'Open data source - Datenquelle öffnen conn.Open "Provider=MSDASQL;Initial Catalog=" & SmartTags("Name_database") & ";DSN="& DSN_NAME &"" 'DSN= Name of the ODBC database - DSN= Name der ODBC-Datenbank 'Writes a data record into a table 'Select data record of the table - Datensatz der Tabelle auswählen 'SQL_Table = "SELECT * FROM " & SmartTags("szTableName") & " WHERE Nr = " & SmartTags("nDat_No") '* = Alle Daten '* = all data SQL_Table = "SELECT * FROM "& SmartTags("Name_table") & " WHERE STT LIKE " & SmartTags("STT_read") 'Execute - Ausführen Set rst = conn.Execute(SQL_Table) rst.MoveFirst 'SmartTags("Val1_syb") = rst.Fields(0).Value SmartTags("Ten_thiet_bi_read")= rst.Fields(1).Value SmartTags("Gia_tri_read") = rst.Fields(2).Value 'Close data source - Datenquelle schließen conn.close Set rst = Nothing Set conn = Nothing End Sub - Thiết kế, lập trình các hệ thống tự động (tủ điều khiển bơm, nhà máy - trạm xử lý nước, ...). - Cung cấp các thiết bị vật tư ngành điện: Máy biến áp, Thiết bị điện LS, Mitsubishi, Schneider. - Lập trình PLC, HMI, hệ thống giám sát SCADA. - Gia công tủ điện các loại. - Email: vancongcodien86@gmail.com

Published by: PLC - Automation Published at: 3 years ago Category: علمی و تکنولوژی