Monday, March 26, 2012

Populate datagrid from XML file using where type query

I am able to populate a datagrid from an XML variable using the
following:
Try
Dim ds As New DataSet
ds.ReadXml(New
StringReader(HttpContext.Current.Application("var").ToString))
dataMeet.DataSource = ds
dataMeet.DataBind()
Catch ex As Exception
error_email.fncErrorHandler(ex)
lblError.Text = ex.ToString
End Try
however this does not allow me to use a sql type query to select
exactly the data I want in the datagrid.
The query I am looking to achieve is actually very simple, just a
simple 'where' but I have no idea how to achieve this when binding to
an xml variable
The sql query and a sample xml file are pasted below:
select TITLE, FIRST_NAME || ' ' || LAST_NAME AS FULL_NAME, DEPT, EMAIL,
PHONE FROM DATABASE.TABLE "
WHERE MEMBERTYPE_CODE = 'MEM' ORDER BY MEMBER_ID
<NewDataSet>
<Table>
<MEMBERTYPE_CODE>OFF</MEMBERTYPE_CODE>
<LAST_NAME>Smith</LAST_NAME>
<FIRST_NAME>Harry</FIRST_NAME>
<TITLE>engineer</TITLE>
<DEPT>engineering</DEPT>
<EMAIL>harry.smith@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1111</PHONE>
</Table>
<Table>
<MEMBERTYPE_CODE>MEM</MEMBERTYPE_CODE>
<LAST_NAME>fred</LAST_NAME>
<FIRST_NAME>bloggs</FIRST_NAME>
<TITLE>Webmaster</TITLE>
<DEPT>Information Technology Services</DEPT>
<EMAIL>fred.blogs@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1112</PHONE>
</Table>
</NewDataSet>
Thank you for your timePerfect, just what I needed!
Thank you

0 comments:

Post a Comment