beautypg.com

Using datasets, Using datasets -7, 3 using datasets – Echelon i.LON 100 e2 Internet Server User Manual

Page 214

background image

i.

LON 100 Internet Server Programmer’s Reference

14-7

s = s & units.Current.Value() & "', '"

Dim statuses As System.Xml.XPath.XpathNodeIterator

dataValues = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTvalue")

timestamps = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTlogTime")

pointNames = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTpointName")

locations = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTlocation")

address=xmlNav.Select("/iLONDataLogger/Log/Element/UCPTlogSourceAddress")

units = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTunit")

statuses = xmlNav.Select("/iLONDataLogger/Log/Element/UCPTpointStatus")

'Process through the XML string returned by the function, and add each

'property to the SQL data table.

While (dataValues.MoveNext())

timestamps.MoveNext()

pointNames.MoveNext()

locations.MoveNext()

address.MoveNext()

units.MoveNext()

statuses.MoveNext()

s = "insert VACOMLOG (timestamp, unit, pointname, value, _

location, address, status) "

s = s & " values('" & timestamps.Current.Value() & "', '"

s = s & pointNames.Current.Value() & "', '"

s = s & dataValues.Current.Value() & "', '"

s = s & locations.Current.Value() & "', '"

s = s & address.Current.Value() & "', '"

s = s & statuses.Current.Value() & "')"

sqlCmd.CommandText = s

sqlCmd.ExecuteNonQuery()

printf(dataValues.Current.Value() & " " & _

timestamps.Current.Value())

End While

14.2.3 Using

DataSets

The following subroutine uses DataSets to construct the input to be supplied to the
DataServerRead function. Using DataSets to construct your XML strings provides several

advantages.
It allows you to assign each property defined in the input string a variable type. This may be
useful if you want to restrict the values a user can assign for a certain property. For example,

by storing the value to be assigned a property like in an Integer

variable, you could limit the values that could be assigned to that property to numbers. In
Visual Basic .NET, types such as UINT16 can further help restrict the user by enforcing user

defined minimum and maximums.

Similarly, by storing the string to be assigned to the on a String

variable, you could limit the length of that description. Generally, using types reduces the

chance of errors occurring in your SOAP message. For example, a user could not attempt to
pass in a string containing letters as the value for an index number, or any other property

that requires an integer as its value type. In addition, performing error checking in your

application will provide responsive error handling.