<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>SQL Server 2005 and .NET Development Blog - DataSet</title>
    <link>http://www.sqlserver2005.org/</link>
    <description>Tips &amp; Tricks zu SQL Server, SQL , .NET Entwicklung,...</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.0.3 - http://www.s9y.org/</generator>
    <pubDate>Fri, 18 May 2007 08:10:47 GMT</pubDate>

    <image>
        <url>http://www.sqlserver2005.org/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: SQL Server 2005 and .NET Development Blog - DataSet - Tips &amp; Tricks zu SQL Server, SQL , .NET Entwicklung,...</title>
        <link>http://www.sqlserver2005.org/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Beziehungen in Expressions im .net Dataset</title>
    <link>http://www.sqlserver2005.org/archives/76-Beziehungen-in-Expressions-im-.net-Dataset.html</link>
            <category>DataSet</category>
    
    <comments>http://www.sqlserver2005.org/archives/76-Beziehungen-in-Expressions-im-.net-Dataset.html#comments</comments>
    <wfw:comment>http://www.sqlserver2005.org/wfwcomment.php?cid=76</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.sqlserver2005.org/rss.php?version=2.0&amp;type=comments&amp;cid=76</wfw:commentRss>
    

    <author>nospam@example.com (Andreas Schindler)</author>
    <content:encoded>
    Im .net Dataset können Beziehungen zwischen Tabellen definiert werden.&lt;br /&gt;
Es ist auch möglich diese Beziehungen in Expressions (zB Rowfilter) zu verwenden. &lt;br /&gt;&lt;a href=&quot;http://www.sqlserver2005.org/archives/76-Beziehungen-in-Expressions-im-.net-Dataset.html#extended&quot;&gt;Continue reading &quot;Beziehungen in Expressions im .net Dataset&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 18 May 2007 10:10:47 +0200</pubDate>
    <guid isPermaLink="false">http://www.sqlserver2005.org/archives/76-guid.html</guid>
    
</item>
<item>
    <title>DataSet Features I</title>
    <link>http://www.sqlserver2005.org/archives/32-DataSet-Features-I.html</link>
            <category>DataSet</category>
    
    <comments>http://www.sqlserver2005.org/archives/32-DataSet-Features-I.html#comments</comments>
    <wfw:comment>http://www.sqlserver2005.org/wfwcomment.php?cid=32</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.sqlserver2005.org/rss.php?version=2.0&amp;type=comments&amp;cid=32</wfw:commentRss>
    

    <author>nospam@example.com (Werner Mairl)</author>
    <content:encoded>
    &lt;p&gt;Hiermit m&amp;ouml;chte ich eine kleine Serie beginnen, in welcher ich diverse Features des .Net DataSets (2.0) etwas genauer erl&amp;auml;utern m&amp;ouml;chte.&lt;/p&gt;&lt;p&gt;Es handelt sich dabei haupts&amp;auml;chlich um Features welche ich teilweise selten bis nie verwendet sehe, oder zu welchen es nur sehr magere Informationen gibt!&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.sqlserver2005.org/archives/32-DataSet-Features-I.html#extended&quot;&gt;Continue reading &quot;DataSet Features I&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 01 Dec 2006 18:36:48 +0100</pubDate>
    <guid isPermaLink="false">http://www.sqlserver2005.org/archives/32-guid.html</guid>
    
</item>
<item>
    <title>Iterationen (foreach) mit DataRow's</title>
    <link>http://www.sqlserver2005.org/archives/3-Iterationen-foreach-mit-DataRows.html</link>
            <category>DataSet</category>
    
    <comments>http://www.sqlserver2005.org/archives/3-Iterationen-foreach-mit-DataRows.html#comments</comments>
    <wfw:comment>http://www.sqlserver2005.org/wfwcomment.php?cid=3</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.sqlserver2005.org/rss.php?version=2.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    

    <author>nospam@example.com (Werner Mairl)</author>
    <content:encoded>
    &lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Folgender Codeabschnitt mag auf den ersten Blick harmlos aussehen, ist in wirklichkeit aber mörderisch:&lt;/font&gt;&lt;/p&gt;&lt;p /&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;private void Do(DataTable table)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;{&lt;/font&gt;&lt;/p&gt;&lt;blockquote dir=&quot;ltr&quot; style=&quot;MARGIN-RIGHT: 0px&quot;&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;foreach (DataRow dr in &lt;strong&gt;table.Rows&lt;/strong&gt;)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;{&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;//dr[0] = ....&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;p /&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Warum ?&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Weil die Rows Collection der DataTable ALLE Rows, unabhängig von Ihrem Zustand sprich RowState zurückgibt!&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Wenn ich aber bei einer gelöschten Row (gelöscht heisst ja nur dass die Row ein spezielles Kennzeichen bekommt, sie wird noch lange nicht aus der DataTable entfernt) auf einen Wert zugreifen will (lesend oder schreibend) dann fliegt mir (zurecht) eine Exception um die Ohren!&lt;/font&gt;&lt;/p&gt;&lt;p /&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Das heisst: bei Iterationen über eine ganze DataTable NIEMALS über die Rows-Collection gehen sondern eine der zwei folgenden Möglichkeiten wählen&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;a) eine DataView dazwischen schalten (Ja DataViews in iherer standardeinstellung filtern gelöschte Rows heraus, auch ein Grund dafür warum gelöschte Rows im Grid nicht mehr angezeigt werden, das Grid verwendet IMMER eine DataView&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;wenn ich wieder mal &amp;quot;zu faul&amp;quot; bin eine eigene DataView zu instantiieren dann verwendet ich&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;table.DefaultView&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;dabei sollte man aber sich sein, dass niemand einen RowFilter auf die DefaultView gesetzt hat (umkehrschluss, RowFilter setze ich immer nur bei explizit erzeugten DataViews ein)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;oder der Andere Weg&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;foreach (DataRow r in &lt;strong&gt;table.Select()&lt;/strong&gt;)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;{&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Select gibt mir ebenfalls nur die gültigen Zeilen zurück und das gleich in einem Array!&lt;/font&gt;&lt;/p&gt;&lt;p /&gt;&lt;p /&gt;&lt;p /&gt;&lt;p /&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Ergänzung:&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Bei der Verwendung von DataRow.Delete gibt es noch ein paar spezielle Probleme&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;foreach(DataRowView drv in table.DefaultView)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;{&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;drv.Row.Delete()&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;kann NICHT verwendet werden da sich durch den Delete-Befehl der Enumerator verändert =&amp;gt; .Net verabschiedet sich mit einer Exception aus der Schleife&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;foreach(DataRow r in table.Rows) &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;kann aus den oben drfestellten Gründen ebenfalls nicht verwendet werden&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;bisher habe ich den Weg über die Sicht verwendet, aber die Rows zuerst in eine ArrayList kopiert und mit einem zweiten foreach über die ArrayList das Delete() aufgerufen. Umständlich aber funktioniert!&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;hier der neueste Lösungsansatz&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;DataRow[] rows = table.select()&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;foreach(DataRow r in rows)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;{&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;r.Delete();&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;läuft intern ähnlich wie die zwischengeschaltete Arraylist, nur dass der Code wesentlich schöner, sauberer, typsicherer und weniger Fehleranfällig ist.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;Der Befehl&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;BACKGROUND-COLOR: #faffff&quot;&gt;DataRow[] rows = table.select()&lt;/font&gt;&lt;/p&gt;&lt;p&gt;bringt uns zwei Dinge:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Select gibt uns nur gültige Rows (ev. bereits vorher gelöschte bekommen wir gar nicht mehr zu sehen, was ja erwünscht ist)&lt;/li&gt;&lt;li&gt;die Ergebnismenge wird in ein Array umkopiert welches wunderbar als Enumerator für das foreach geeignet ist da es sich durch Delete() nicht ändert!&lt;/li&gt;&lt;li /&gt;&lt;/ol&gt;&lt;p /&gt;&lt;p /&gt;&lt;p /&gt; 
    </content:encoded>

    <pubDate>Mon, 20 Nov 2006 15:07:08 +0100</pubDate>
    <guid isPermaLink="false">http://www.sqlserver2005.org/archives/3-guid.html</guid>
    
</item>

</channel>
</rss>