DataColumn Expression Property
August 20, 2008 by Rakesh Bindal
Gets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column.
An expression to calculate the value of a column, or create an aggregate column. The return type of an expression is determined by the DataType of the column.
'Dataset is created through Xmldocument
Dim objXmlDoc As New XmlDocument()
Dim objXmlReader As XmlNodeReader
Dim objDS As New DataSet()
Dim inttotal As Integer = 0
Dim dc As New DataColumn("tempSalary", GetType(System.Int32))
objXmlDoc.LoadXml('< Employees> <emp id='100' name='abc' sal='2000' /> <emp id='101' name='def' sal='3000' /> <emp id='102' name='prq' sal='8000' /> <emp id='103' name='xyz' sal='10000' /> </Employees>')
objXmlReader = New XmlNodeReader(objXmlDoc)
objDS.ReadXml(objXmlReader)
objDS.Tables(0).Columns.Add(dc)
objDS.Tables(0).Columns("tempSalary").Expression = "Convert(sal,'System.Int32')"
inttotal = Convert.ToInt32(objDS.Tables(0).Compute("sum(tempSalary)", ""))