<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>ADO.NET</title><link>http://www.michaelfalconer.co.uk/category/14.aspx</link><description>ADO.NET</description><managingEditor>Michael Falconer</managingEditor><dc:language>en-GB</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Michael D. Falconer</dc:creator><title>Filtering a DataView based on the value of a child record</title><link>http://www.michaelfalconer.co.uk/archive/2004/05/20/156.aspx</link><pubDate>Thu, 20 May 2004 13:29:00 GMT</pubDate><guid>http://www.michaelfalconer.co.uk/archive/2004/05/20/156.aspx</guid><description>&lt;P&gt;I've been developing a Windows Form application&amp;nbsp;in VB.NET, and came across an interesting puzzle when trying to filter the contents of a ListBox based on a value in a child record.&lt;/P&gt;
&lt;P&gt;To explain a bit more, I have a DataSet that contains a table with records of courses and a&amp;nbsp;related table of qualifications. A course can have more than one qualification. I have a DataView based on the course table, and wanted to filter it based on a selected qualification. The RowFilter property of the DataView allows you to select a child row using Child.Row or Child(Relationship).Row in the expression. But to quote the documentation: 'because child relationships may return multiple rows, you must include the reference to the child column in an aggregate function.'. I hoped that I could therefore do something like:&lt;/P&gt;
&lt;P&gt;Count(Child.qualification='Masters')&amp;gt;0&lt;/P&gt;
&lt;P&gt;Sadly, no. This simlpy returns the following error:&lt;/P&gt;
&lt;P&gt;"Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier."&lt;/P&gt;
&lt;P&gt;So, it appeared that you can't apply a filter to a Child element in the filter expression. My solution to the problem was to add a new boolean column to the course DataTable, and then update the value of it depending on the selected value using an XPath query. It does mean that you have to reset the values of the column each tmie the filter value is changed, but for this application that approach appears to work fine, without any major performance penalties.&lt;/P&gt;
&lt;P&gt;Hopefully, though, this will be something that's looked at in a future version of .net...&lt;/P&gt;&lt;img src ="http://www.michaelfalconer.co.uk/aggbug/156.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Michael D. Falconer</dc:creator><title>Binding to distinct records in a DataSet</title><link>http://www.michaelfalconer.co.uk/archive/2004/05/17/152.aspx</link><pubDate>Mon, 17 May 2004 15:57:00 GMT</pubDate><guid>http://www.michaelfalconer.co.uk/archive/2004/05/17/152.aspx</guid><description>&lt;P&gt;My latest puzzle has been how to bind a listbox to distinct records in a DataTable within a Dataset. As there is no method of selecting distinct records from a view, Microsoft's solution is to &lt;A href="http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B325684" target=_blank&gt;Implement a DataSet SELECT DISTINCT Helper Class in Visual Basic .NET&lt;/A&gt;. I've used this approach, and it works, but I can't help but feel it's not the most efficient way.&lt;/P&gt;
&lt;P&gt;Anyone have any other ideas or solutions to this?&lt;/P&gt;&lt;img src ="http://www.michaelfalconer.co.uk/aggbug/152.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>