Question:
How can I load a query’s result into an internal tag?
Solution:
To do so, you must use query’s GetADORecordset() method.
In the script below, the query on the main screen is executed, and the values of “DemoTag1” to “DemoTag2” are loaded into “InternalTag1″ to ” InternalTag12″ internal tags:
Screen.Item(“Query1”).Execute(ImediateExecute)
Set rs = Screen.Item(“Query1”).GetADORecordset()
If rs.recordcount > 0 Then
For aux = 1 to rs.fields.count
Application.GetObject(“InternalTag.InternalTag” & aux).Value = rs.fields.Item(“DemoTag” & aux).Value
Next
End if
Set rs = Screen.Item(“Query1”).GetADORecordset()
If rs.recordcount > 0 Then
For aux = 1 to rs.fields.count
Application.GetObject(“InternalTag.InternalTag” & aux).Value = rs.fields.Item(“DemoTag” & aux).Value
Next
End if
The query on the initial screen is:
SELECT TOP 1 Historic.DemoTag1,Historic.DemoTag2,Historic.DemoTag3,
Historic.DemoTag4,Historic.DemoTag5,Historic.DemoTag6,Historic.DemoTag7,
Historic.DemoTag8,Historic.DemoTag9,Historic.DemoTag10,Historic.DemoTag11,
Historic.DemoTag12
FROM Historic
ORDER BY E3TimeStamp DESC
Historic.DemoTag4,Historic.DemoTag5,Historic.DemoTag6,Historic.DemoTag7,
Historic.DemoTag8,Historic.DemoTag9,Historic.DemoTag10,Historic.DemoTag11,
Historic.DemoTag12
FROM Historic
ORDER BY E3TimeStamp DESC
NOTE: Attached to this article is a sample application developed with E3 version 3.1 Build 270.