<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6430580789303964192</id><updated>2024-09-01T12:19:55.705+02:00</updated><category term="SQL"/><category term="SQL-Server"/><category term=".Net"/><category term="C#"/><category term="Datenbank"/><category term="Transaktion"/><category term="SQLite"/><category term="ASP.Net"/><category term="BulkInsert"/><category term="MonoTouch"/><category term="Trigger"/><category term="UserGroup"/><category term="Verbindungsserver"/><category term="Windows CE"/><category term="Windows Mobile"/><category term="Base64"/><category term="DataBind()"/><category term="DatenTypen"/><category term="DropDownList"/><category term="EGOPhotoView"/><category term="Enum"/><category term="Exception"/><category term="Index"/><category term="MD5"/><category term="Oracle"/><category term="Performance"/><category term="REST"/><category term="Service Broker"/><category term="Table-Lock"/><category term="Timeout"/><category term="UITextView"/><category term="UpdatePanel"/><category term="Version"/><category term="Webservice"/><title type='text'>Schnorchlie&#39;s Select&#39;ion</title><subtitle type='html'>Grundlagen, Tipps &amp;amp; Tricks rund um den Microsoft SQL-Server und .Net</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-1032776595410606947</id><published>2019-07-10T10:36:00.001+02:00</published><updated>2019-07-10T10:37:48.762+02:00</updated><title type='text'>Deutsche Glasfaser</title><content type='html'>&lt;a href=&quot;https://www.awin1.com/awclick.php?gid=332748&amp;amp;mid=11463&amp;amp;awinaffid=621305&amp;amp;linkid=2132338&amp;amp;clickref=&quot;&gt;Deutsche Glasfaser Produktübersicht&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;!-- START ADVERTISER: Deutsche Glasfaser DE from awin.com --&gt;

&lt;a href=&quot;https://www.awin1.com/cread.php?s=2194979&amp;v=11463&amp;q=340975&amp;r=621305&quot;&gt;
    &lt;img src=&quot;https://www.awin1.com/cshow.php?s=2194979&amp;v=11463&amp;q=340975&amp;r=621305&quot; border=&quot;0&quot;&gt;
&lt;/a&gt;

&lt;!-- END ADVERTISER: Deutsche Glasfaser DE from awin.com --&gt;
</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/1032776595410606947/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2019/07/deutsche-glasfaser.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1032776595410606947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1032776595410606947'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2019/07/deutsche-glasfaser.html' title='Deutsche Glasfaser'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-100622473259131554</id><published>2015-08-07T11:43:00.000+02:00</published><updated>2015-08-07T11:44:21.542+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="UserGroup"/><title type='text'>UG Göttingen: Nach der Sommerpause schauen wir uns mal Roslyn an</title><content type='html'>Nach der Sommerpause im August, treffen wir uns ab September wieder. Dann wird es auch ausnahmsweise nicht am ersten Donnerstag im Monat sondern am 10. September 2015 stattfinden.&lt;br /&gt;
&lt;div&gt;
Nähere Informationen gibt es wie immer auf der &lt;a href=&quot;http://www.dotnetgoe.de/?p=775&quot; target=&quot;_blank&quot;&gt;Homepage der UG&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/100622473259131554/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2015/08/ug-gottingen-nach-der-sommerpause.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/100622473259131554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/100622473259131554'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2015/08/ug-gottingen-nach-der-sommerpause.html' title='UG Göttingen: Nach der Sommerpause schauen wir uns mal Roslyn an'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-1552029756918286395</id><published>2014-06-25T14:45:00.000+02:00</published><updated>2015-08-07T11:37:09.402+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Datenbank"/><category scheme="http://www.blogger.com/atom/ns#" term="Service Broker"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><title type='text'>Automatische Kommunikation zur Datenbank via Service Broker</title><content type='html'>&lt;h5&gt;
(Automatically communication to a database via Service Broker)&lt;/h5&gt;
Es gibt viele verschiedene Arten aus einem .Net-Programm auf eine Datenbank zuzugreifen und Daten auszulesen. Möchte man jedoch auf inhaltliche Änderungen einer Tabelle (z. B. Schnittstellentabelle) zeitnah reagieren, sollte man sich schon vorher ein paar Gedanken über die Abfragemethodik machen, um überflüssige Last zu vermeiden.&lt;br /&gt;
Die einfachste Möglichkeit Änderungen mitzubekommen, wäre wohl ein Timer, welcher in regelmäßigen Intervallen die Tabelle abfragt. Um hier aber zeitnah reagieren zu können, müsste der Intervall entsprechend kurz eingestellt werden. Dieses wiederum hätte wahrscheinlich viele unnötige Abfragen zur Folge, die folglich auch wieder Last auf dem SQL-Server verursachen. &lt;br /&gt;
Um dieses Verhalten zu umgehen, könnte man den Weg über den sogenannten Service Broker gehen, der im SQL-Server (im Datenbankmodul) integriert ist. Der Service Broker wird für komplette Datenbank aktiviert. In der Programmierung steuert man dann gezielt die Tabellen an. Der Service Broker dient zur asynchronen Kommunikation zwischen SQL-Server und externen Anwendung. Außerdem arbeitet der Service Broker mit Warteschlangen, so dass generell keine Informationen verloren gehen sollten.&lt;br /&gt;
Zum Aktivieren des Service Brokers (im Management Studio) in der Datenbank muss man wie folgt vorgehen:&lt;br /&gt;- Öffnen der Datenbank-Eigenschaften (Rechtsklick auf Datenbank =&amp;gt; Eigenschaften/Properties)&lt;br /&gt;- Auswählen von Optionen/Options&lt;br /&gt;- Die Option “Broker aktivieren” / “Broker enabled” auf True setzen&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://lh3.ggpht.com/-9eLmuZByvrg/U6rEcsJe5kI/AAAAAAAAATM/4Db-sWma7S8/s1600-h/ServiceBroker%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;ServiceBroker&quot; border=&quot;0&quot; src=&quot;http://lh4.ggpht.com/-F7Seu1oV8Gg/U6rEd6Ia6wI/AAAAAAAAATU/tQuctXr8U0I/ServiceBroker_thumb%25255B1%25255D.png?imgmax=800&quot; height=&quot;456&quot; style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;ServiceBroker&quot; width=&quot;521&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Mit der Aktivierung des Service Brokers funktioniert die Kommunikation zur Datenbank generell.&lt;br /&gt;Nun kann dieser auch direkt im .Net angesprochen werden. Hierfür gibt es die Klasse SqlDependency.&lt;br /&gt;Hier braucht man quasi nur die Verbindung starten und ein EventHandler hinterlegen, wo die Verarbeitung der Änderungen definiert ist.&lt;br /&gt;
&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.5%;&quot;&gt;
&lt;pre id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; StartWatcher()
{
    String connectionString = &lt;span style=&quot;color: #006080;&quot;&gt;&quot;Server=(local);Database=Playground;Trusted_Connection=True;&quot;&lt;/span&gt;;
    SqlDependency.Start(connectionString);
    ReadData();
}


&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; ReadData()
{
    DataTable data = GetNewData();

    &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (data != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; data.Rows.Count &amp;gt; 0)
    {
        ChangeEventArgs daten = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; ChangeEventArgs(data.Rows[0]);
        ChangeEventHandler(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, daten);
    }
}


&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; DataTable GetNewData()
{
    DataTable dt = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; DataTable();
    
    &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; (SqlConnection conn = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlConnection(ConnectionString))
    {
        conn.Open();

        SqlCommand cmd = conn.CreateCommand();
                
        cmd.CommandText = SELECT ID, Name, DescriptionShort FROM dbo.Product WHERE State = @State&lt;span style=&quot;color: #006080;&quot;&gt;&quot;;
        cmd.Notification = null;

        cmd.Parameters.Add(new SqlParameter(&quot;&lt;/span&gt;@State&lt;span style=&quot;color: #006080;&quot;&gt;&quot;, &quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&quot;));

        dep = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlDependency(cmd);
        dep.OnChange += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; OnChangeEventHandler(dep_OnChange);

        SqlDataAdapter adapter = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlDataAdapter();
        adapter.SelectCommand = cmd;
        adapter.Fill(dt);

        conn.Close();
    }

    &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; dt;
}


&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; ChangeEventArgs : EventArgs
{
    &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;readonly&lt;/span&gt; DataRow data;

    &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; ChangeEventArgs(DataRow data)
    {
        &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.data = data;
    }
}


&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; dep_OnChange(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, SqlNotificationEventArgs e)
{
    ReadData();
}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Im gezeigten Beispiel wird nun also direkt die Verarbeitung des Handlers ausgeführt, sobald ein neuer Datensatz mit dem Status “new” in die Tabelle Product eingefügt wird.&lt;br /&gt;
&lt;br /&gt;
Für die Abfragen in Verbindung mit dem Service Broker gibt es ein paar kleinere Spielregeln zu beachten, welche im MSDN zu finden sind. Eine wichtige Regel, über die ich gestolpert bin ist, dass die Abfragen z.B. SELECTS nicht mit Platzhaltern wie * verwendet werden dürfen. Hier muss man gezielt Spalten angeben, die abgefragt/eingelesen werden sollen.</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/1552029756918286395/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/automatische-kommunikation-zur.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1552029756918286395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1552029756918286395'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/automatische-kommunikation-zur.html' title='Automatische Kommunikation zur Datenbank via Service Broker'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-F7Seu1oV8Gg/U6rEd6Ia6wI/AAAAAAAAATU/tQuctXr8U0I/s72-c/ServiceBroker_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-5932146789288599685</id><published>2014-06-24T21:59:00.001+02:00</published><updated>2014-06-24T21:59:24.540+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="UserGroup"/><title type='text'>UG Göttingen: Wir gehen in die Sommerpause!</title><content type='html'>&lt;p&gt;Nach interner Abstimmung haben wir uns dafür entschieden in eine verlängerte Sommerpause zu gehen und die kommenden beiden Monate zu pausieren. Damit steht fest, dass in den Monaten Juli und August kein UserGroup Treffen stattfindet.&lt;/p&gt; &lt;p&gt;Nähere Informationen zum nächsten Treffen sind wie immer auf der UG-Webseite zu finden.&lt;br&gt;&lt;a title=&quot;http://dotnetgoettingen.de/&quot; href=&quot;http://dotnetgoettingen.de/&quot;&gt;http://dotnetgoettingen.de/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Bei Entzugserscheinungen gibt es die Ausweichmöglichkeit ein oder zwei schöne Abende bei der UG Braunschweig zu verbringen.&lt;br&gt;Da ich aber noch nicht weiß, ob es hier auch eine Sommerpause gibt, sollte man sich vielleicht vorher noch einmal informieren.&lt;br&gt;Nähere Information entweder direkt bei Lars Keller erfragen oder auf der Homepage nachschauen.&lt;br&gt;&lt;a title=&quot;http://www.dotnet-braunschweig.de/&quot; href=&quot;http://www.dotnet-braunschweig.de/&quot;&gt;http://www.dotnet-braunschweig.de/&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/5932146789288599685/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/ug-gottingen-wir-gehen-in-die.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5932146789288599685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5932146789288599685'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/ug-gottingen-wir-gehen-in-die.html' title='UG Göttingen: Wir gehen in die Sommerpause!'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-8999273093854750506</id><published>2014-06-12T10:30:00.001+02:00</published><updated>2014-06-12T10:33:11.798+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BulkInsert"/><category scheme="http://www.blogger.com/atom/ns#" term="Datenbank"/><category scheme="http://www.blogger.com/atom/ns#" term="Index"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Transaktion"/><title type='text'>Deaktivieren und Aktivieren von Indizes per SQL-Script</title><content type='html'>&lt;h5&gt;(SQL-Server: Disable or Enable Index per SQL-Script) &lt;/h5&gt; &lt;p&gt;Manchmal ist es sinnvoll vor bestimmten Operationen (zum Beispiel Massenverarbeitungen per Bulk Insert oder Bulk Copy) Indizes auszublenden.Eine Möglichkeit wäre hier das Löschen und Erstellen des betroffenen Index. Sollte hierbei aber ein Fehler auftreten und man arbeitet nicht in einer Transaktion, dann kann es passieren, dass der Index komplett gelöscht bleibt.&lt;/p&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;USE&lt;/span&gt; [Playground]&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Drop the Index &quot;ProductIndex1&quot;&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;DROP&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INDEX&lt;/span&gt; [ProductIndex1] &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product]&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Create the Index &quot;ProductIndex1&quot;&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NONCLUSTERED&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INDEX&lt;/span&gt; [ProductIndex1] &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product]&lt;br&gt;(&lt;br&gt;    [ID] &lt;span style=&quot;color: #0000ff&quot;&gt;ASC&lt;/span&gt;&lt;br&gt;)&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;WITH&lt;/span&gt; &lt;br&gt;(&lt;br&gt;    PAD_INDEX = &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;, &lt;br&gt;    STATISTICS_NORECOMPUTE = &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;, &lt;br&gt;    SORT_IN_TEMPDB = &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;, &lt;br&gt;    DROP_EXISTING = &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;, &lt;br&gt;    ONLINE = &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;, &lt;br&gt;    ALLOW_ROW_LOCKS = &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt;, &lt;br&gt;    ALLOW_PAGE_LOCKS = &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt;&lt;br&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [&lt;span style=&quot;color: #0000ff&quot;&gt;PRIMARY&lt;/span&gt;]&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Meiner Meinung nach ist die schönere Variante, das Deaktivieren mit anschließendem Reaktivieren bzw. Neu-Aufbau.&lt;/p&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;USE&lt;/span&gt; [Playground]&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Diable the Index &quot;ProductIndex1&quot;&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INDEX&lt;/span&gt; [ProductIndex1] &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product] DISABLE&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Enable and Rebuild the Index &quot;ProductIndex1&quot;&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INDEX&lt;/span&gt; [ProductIndex1] &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product] REBUILD&lt;br&gt;GO&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/8999273093854750506/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/disable-or-enable-index-per-sql-script.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8999273093854750506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8999273093854750506'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/disable-or-enable-index-per-sql-script.html' title='Deaktivieren und Aktivieren von Indizes per SQL-Script'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-4241508950037112058</id><published>2014-06-05T14:39:00.001+02:00</published><updated>2014-06-05T14:40:39.263+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Datenbank"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Transaktion"/><title type='text'>SQL-Server: Neue Spalte an bestimmter Position in Tabelle einfügen</title><content type='html'>&lt;h5&gt;(SQL-Server: Insert column at a special position in a table)&lt;/h5&gt; &lt;p&gt;In seltenen Fällen kann es doch mal notwendig sein, dass man eine neue Spalte an einer bestimmten Position in einer Tabelle einfügen und diese nicht einfach am Ende anfügen will. Leider gibt es es hierfür keine “einfache” Funktion. Über das SQL Server Management Studio (SSMS) gibt es zwar diese Möglichkeit, jedoch geht es nur, wenn die betroffene Tabelle noch nicht gefüllt ist oder gelöscht werden darf.&lt;/p&gt; &lt;p&gt;Wie geht das Management Studio aber (grob gesagt) intern vor?&lt;br&gt;1. Die betroffene Tabelle wird mit neuen Spalten als temporäre Tabelle erstellt.&lt;br&gt;2. Die Inhalte werden aus der originalen Tabelle in die temporäre Tabelle kopiert.&lt;br&gt;3. Die originale Tabelle wird gelöscht.&lt;br&gt;4. Die temporäre Tabelle wird umbenannt und als permanente Tabelle bereitgestellt.&lt;/p&gt; &lt;p&gt;Genau nach dieser Vorgehensweise habe ich nun ein SQL-Skript geschrieben, welches eine neue Spalte an einer beliebigen Position einer Tabelle einfügt und dabei keine Daten verliert.&lt;/p&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; height: 246px; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;USE&lt;/span&gt; [Spielwiese]&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt; TRY&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRAN&lt;/span&gt; TransactionInsertColumn;&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Create a new table with the additional column (DescriptionShort)&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; [dbo].[Product_NEW] (&lt;br&gt;        [ID]                       &lt;span style=&quot;color: #0000ff&quot;&gt;INT&lt;/span&gt;           &lt;span style=&quot;color: #0000ff&quot;&gt;IDENTITY&lt;/span&gt; (1, 1) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,&lt;br&gt;        [Name]                     &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt; (50)  &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,&lt;br&gt;        [DescriptionShort]        &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt; (50)  &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,&lt;br&gt;        [Description]             &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt; (255) &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;&lt;br&gt;    );&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;IDENTITY_INSERT&lt;/span&gt; [Product_NEW] &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt;;&lt;br&gt;    &lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Copy all data from the original table to the new (extended) one&lt;/span&gt;&lt;br&gt;    INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; [Product_NEW]&lt;br&gt;               ([ID]&lt;br&gt;               ,[Name]&lt;br&gt;               ,[DescriptionShort] &lt;span style=&quot;color: #008000&quot;&gt;-- This is the new inserted column&lt;/span&gt;&lt;br&gt;               ,[Description]&lt;br&gt;               )&lt;br&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; [ID]&lt;br&gt;                ,[Name]&lt;br&gt;                ,&lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: #008000&quot;&gt;-- Content of the new column is NULL (or can set here)&lt;/span&gt;&lt;br&gt;                ,[Description]                &lt;br&gt;      &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; [Product]&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;IDENTITY_INSERT&lt;/span&gt; [Product_NEW] &lt;span style=&quot;color: #0000ff&quot;&gt;OFF&lt;/span&gt;;&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Rename the original table to _OLD&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;EXEC&lt;/span&gt; sp_rename &lt;span style=&quot;color: #006080&quot;&gt;&#39;Product&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&#39;Product_OLD&#39;&lt;/span&gt;;&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Rename the new table to the original name&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;EXEC&lt;/span&gt; sp_rename &lt;span style=&quot;color: #006080&quot;&gt;&#39;Product_NEW&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&#39;Product&#39;&lt;/span&gt;;&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Drop the old table&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;DROP&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; Product_OLD;&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Optional: Create index here&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NONCLUSTERED&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INDEX&lt;/span&gt; [ProductIndex1]&lt;br&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product]([Id] &lt;span style=&quot;color: #0000ff&quot;&gt;ASC&lt;/span&gt;);    &lt;br&gt;    &lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Optional: Create primary key here&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; [Product]&lt;br&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;CONSTRAINT&lt;/span&gt; [Product_PK] &lt;span style=&quot;color: #0000ff&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;CLUSTERED&lt;/span&gt; ([ID] &lt;span style=&quot;color: #0000ff&quot;&gt;ASC&lt;/span&gt;);&lt;br&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- Optional: Create foreign keys here&lt;/span&gt;&lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; [Product]&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;--    ADD CONSTRAINT [FKProductHeaderID] FOREIGN KEY ([FKProductHeader]) REFERENCES [ProductHeader] ([ProductID]);&lt;/span&gt;&lt;br&gt;    &lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- NOTE:&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #008000&quot;&gt;-- All rights (grant/deny) are lost and have to set new&lt;/span&gt;&lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;GRANT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product] &lt;span style=&quot;color: #0000ff&quot;&gt;TO&lt;/span&gt; &quot;RoleReadOnly&quot;;&lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;GRANT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [Product] &lt;span style=&quot;color: #0000ff&quot;&gt;TO&lt;/span&gt; &quot;RoleReadWrite&quot;;&lt;br&gt;    &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;COMMIT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRAN&lt;/span&gt; TransactionInsertColumn;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt; TRY&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt; CATCH&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; ERROR_MESSAGE(), ERROR_NUMBER() &lt;span style=&quot;color: #008000&quot;&gt;-- Show the last error message if the transaction was aborted&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRAN&lt;/span&gt; TransactionInsertColumn&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt; CATCH&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/4241508950037112058/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/sql-server-neue-spalte-bestimmter.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/4241508950037112058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/4241508950037112058'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2014/06/sql-server-neue-spalte-bestimmter.html' title='SQL-Server: Neue Spalte an bestimmter Position in Tabelle einfügen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-3804387737337874117</id><published>2014-03-27T10:18:00.000+01:00</published><updated>2014-03-27T10:51:57.621+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Datenbank"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Trigger"/><title type='text'>Ausgeführte SQL-Statements ermitteln bzw. loggen</title><content type='html'>&lt;p&gt;In speziellen Fällen ist es manchmal sinnvoll, wenn man gezielt Datenbankabfragen protokolliert.&lt;br&gt;Eine einfache Möglichkeit wäre ein Tabellen-Trigger, in dem das ausgeführte SQL-Statement ermittelt und beispielsweise in eine eigene Log-Tabelle geschrieben wird.&lt;br&gt;&lt;br&gt;Ein Trigger, der als Ergebnis das ausgeführte Statement zurückgibt, könnte wie folgt erstellt werden.&lt;/p&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRIGGER&lt;/span&gt; GetSqlStatement&lt;br&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;ON&lt;/span&gt; [dbo].[Produkte] &lt;br&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;AFTER&lt;/span&gt; INSERT, &lt;span style=&quot;color: #0000ff&quot;&gt;UPDATE&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;DELETE&lt;/span&gt; &lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; &lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;DECLARE&lt;/span&gt; @TEMP &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; &lt;br&gt;    (EventType NVARCHAR(30), &lt;span style=&quot;color: #0000ff&quot;&gt;Parameters&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INT&lt;/span&gt;, EventInfo NVARCHAR(4000)) &lt;br&gt;    INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; @TEMP &lt;span style=&quot;color: #0000ff&quot;&gt;EXEC&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&#39;DBCC INPUTBUFFER(@@SPID)&#39;&lt;/span&gt;) &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; EventInfo &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; @TEMP &lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt;&lt;br&gt;GO&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Wenn man nun ein DML-Statement wie z.B. ein Insert auf die entsprechende Tabelle absetzt, wird der Trigger ausgeführt und das gerade ausgeführte Statement zurückgegeben.&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://lh4.ggpht.com/-1Ht0_fcvsBo/UzP0uMmQplI/AAAAAAAAAOU/8REaV447jAw/s1600-h/GetStatement%25255B8%25255D.png&quot;&gt;&lt;img title=&quot;GetStatement&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;GetStatement&quot; src=&quot;http://lh3.ggpht.com/-XlvDAxbS6vw/UzP0umhtmMI/AAAAAAAAAOc/697HGEml6cg/GetStatement_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;674&quot; height=&quot;140&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So hätte man die Möglichkeit direkt im Trigger das Statement (EventInfo) wie gewünscht zu protokollieren. Es würden so jegliche inhaltliche Änderungen der Daten gespeichert werden.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/3804387737337874117/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2014/03/ausgefuhrte-sql-statements-ermitteln.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3804387737337874117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3804387737337874117'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2014/03/ausgefuhrte-sql-statements-ermitteln.html' title='Ausgeführte SQL-Statements ermitteln bzw. loggen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-XlvDAxbS6vw/UzP0umhtmMI/AAAAAAAAAOc/697HGEml6cg/s72-c/GetStatement_thumb%25255B5%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-8647349052363455586</id><published>2013-03-24T15:04:00.000+01:00</published><updated>2014-03-27T10:30:19.512+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Transaktion"/><title type='text'>Transaktionen SAVEPOINT</title><content type='html'>&lt;p&gt;Arbeitet man in einer Transaktion und möchte im Fehlerfall nicht die komplette Transaktion sondern nur einen speziellen Code-Abschnitt zurückspielen, so kann man mit sogenannten Savepoints arbeiten.  &lt;p&gt;Von diesen Haltepunkten kann man beliebig viele setzen.&lt;br&gt;Auch hier ist es wieder ratsam einen Namen pro Savepoint zu vergeben, um diesen später gezielt anzusprechen.&lt;/p&gt; &lt;p&gt;Einen Savepoint setzt man wie folgt:&lt;/p&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Savepoint setzen &lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SAVE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; sp1&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Um von der aktuellen (Verarbeitungs-)Position in der Transaktion alles bis zu einem Savepoint zurückzusetzen muss man das ROLLBACK wie folgt aufrufen, wobei sp1 der Name des Savepoints ist.&lt;/p&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Zurückspielen der Transaktion bis zum angegebene Savepoint&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; sp1 &lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Beispiel:&lt;/p&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; Farben&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;VALUES&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&#39;rot&#39;&lt;/span&gt;) &lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SAVE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; sp1 &lt;br&gt;&lt;br&gt;INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; Farben&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;VALUES&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&#39;blau&#39;&lt;/span&gt;) &lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Rollback bis zum Savepoint sp1 durchführen&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Die Farbe &quot;blau&quot; wird entfernt&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Die Farbe &quot;rot bleibt weiterhin bestehen&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; sp1 &lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Die gesamte Transaktion wird zurückgeschrieben&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Die Farbe &quot;blau&quot; wird entfernt&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Die Farbe &quot;rot wird entfernt&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; &lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Hinweis:&lt;br&gt;Hier unterscheidet sich die Verarbeitung zwischen Oracle und MSSQL-Server.&lt;br&gt;Beim MSSQL-Server wird der Savepoint bei einen Rollback mit verworfen.&lt;br&gt;Bei Oracle hingegen bleibt dieser bestehen. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Außerdem unterscheidet sich die Syntax bei Oracle wie folgt:&lt;/p&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Savepoint setzen &lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SAVEPOINT&lt;/span&gt; sp1 &lt;br&gt;&lt;br&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Rollback bis zum Savepoint&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TO&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;SAVEPOINT&lt;/span&gt; sp1&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/8647349052363455586/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/transaktionen-savepoint.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8647349052363455586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8647349052363455586'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/transaktionen-savepoint.html' title='Transaktionen SAVEPOINT'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-9032940498030653704</id><published>2013-03-20T16:00:00.000+01:00</published><updated>2014-03-27T10:32:36.295+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Transaktion"/><title type='text'>Benannte Transaktionen</title><content type='html'>&lt;p&gt;Bei der Verwendung von mehreren Transaktionen in einem Skript, ist es übersichtlicher wenn man die einzelnen Transaktionen benennt.&lt;br&gt;&lt;br&gt;Dieses kann man einfach machen, indem man einen beliebigen Namen hinter das TRANSACTION hängt. &lt;br&gt;Es ist dabei wichtig, dass man den Namen im weiteren Verlauf wie z.B. beim COMMIT oder ROLLBACK immer angibt.&lt;br&gt;&lt;br&gt;Beispiel:&lt;br&gt;&lt;br&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; BeispielTransaktion;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; BeispielTransaktion;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;COMMIT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TRANSACTION&lt;/span&gt; BeispielTransaktion;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/9032940498030653704/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/benannte-transaktionen.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/9032940498030653704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/9032940498030653704'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/benannte-transaktionen.html' title='Benannte Transaktionen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-6741953108409412089</id><published>2013-03-19T20:45:00.000+01:00</published><updated>2013-03-19T21:02:30.562+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Transaktion"/><title type='text'>TRANSACTION! COMMIT? ROLLBACK?</title><content type='html'>&lt;p&gt;Oft sieht mit in SQL-Skripten, die mit Transaktionen arbeiten folgende oder ähnliche Abfrage:&lt;/p&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;-- Transaktion rückgängig machen&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;IF&lt;/span&gt; &lt;span class=&quot;preproc&quot;&gt;@@TRANCOUNT&lt;/span&gt; &amp;gt; 0
    &lt;span class=&quot;kwrd&quot;&gt;ROLLBACK&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;TRANSACTION&lt;/span&gt;; &lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, &quot;Courier New&quot;, courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Aber was genau steckt eigentlich dahinter?&lt;br&gt;Eigentlich ist diese Abfrage mehr oder weniger Quatsch bzw. falsch. &lt;/p&gt;
&lt;p&gt;Die globale Variable @@TRANCOUNT gibt nur die Anzahl der mit &quot;BEGIN TRANSACTION&quot; geöffneten Transaktionen zurück.&lt;br&gt;Das heißt, an dieser Stelle wird geprüft, ob es eine offene Transaktion gibt. Wenn dieses der Fall ist, dann wird eine (die zuletzt geöffnete) geschlossen. 
&lt;p&gt;An dieser Stelle weiß man jedoch nicht, ob die Transaktion erfolgreich oder fehlerhaft war.&lt;br&gt;Also könnte man auch nicht sagen, ob diese bestätigt (commit) oder zurückgeschrieben (rollback) werden sollen.&lt;br&gt;Diese Information bekommt man aber ganz einfach direkt über eine SQL-Server-Funktion. 
&lt;p&gt;Über die Systemfunktion XACT_STATE() kann der aktuelle Transaktionsstatus manuell geprüft werden.&lt;br&gt;Mögliche Rückgabewerte sind folgende:&lt;br&gt;# 1 =&amp;gt; Es ist eine Transaktion vorhanden, die korrekt verarbeitet wurde und committed werden kann.&lt;br&gt;# 0 =&amp;gt; Es ist keine Transaktion vorhanden.&lt;br&gt;# -1 =&amp;gt; Es ist eine Transaktion vorhanden, die aber fehlerhaft verarbeitet wurde und nicht committed werden kann. Diese Transaktion kann nur noch vollständig per ROLLBACK zurückgeschrieben werden. 
&lt;p&gt;Anhand dieser Funktion kann man also die Transaktion bzw. dessen Status prüfen und diese bestätigen oder zurückschreiben. 
&lt;p&gt;Möchte man die Transaktion nicht manuell zurückschreiben, dann könnte man dieses auch automatisch vom SQL-Server machen lassen. In diesem Fall gilt nur zu beachten, dass die Transaktion trotzdem bei erfolg bestätigt werden muss. 
&lt;p&gt;XACT_ABORT(ON/OFF) ist eine Eigenschaft die über SET beliebig eingestellt werden kann.&lt;br&gt;Diese Eigenschaft gibt an ob eine fehlgeschlagene Transaktion automatisch zurückgeschrieben werden soll. 
</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/6741953108409412089/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/transaction-commit-rollback.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/6741953108409412089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/6741953108409412089'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/transaction-commit-rollback.html' title='TRANSACTION! COMMIT? ROLLBACK?'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-1031390976505115543</id><published>2013-03-12T19:00:00.000+01:00</published><updated>2013-03-12T19:00:04.402+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><title type='text'>Einfaches Arbeiten mit Transaktionen</title><content type='html'>&lt;br&gt;Eine Transaktion bezeichnet eine Gruppe von Datenbankabfragen, welche nur gemeinsam ausgeführt werden können.&lt;br&gt;&lt;br&gt;Dieses ist in ganz unterschiedlichen Bereichen wie z.B. in der Lagerlogistik bei einer Lagerumbuchung notwendig.&lt;br&gt;Wird ein Artikel von einem Lagerplatz auf einen anderen verschoben, so darf zwischen der Entnahme- und der Ziel-Buchung keine Möglichkeit für Eingriffe bestehen.&lt;br&gt;Ansonsten könnte es zu Problemen kommen und ein Artikel könnte doppelt verbucht werden.&lt;br&gt;&lt;br&gt;Einfach gesagt, bündeln Transaktionen also nur mehrere SQL-Abfragen.&lt;br&gt;Eine Transaktion muss immer geöffnet und auch wieder geschlossen werden.&lt;br&gt;&lt;br&gt;Öffnen kann man eine Transaktion so:&lt;br&gt;&lt;span style=&quot;white-space: pre&quot; class=&quot;Apple-tab-span&quot;&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; &lt;span style=&quot;color: #008000&quot;&gt;-- Transaktion starten&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=BEGIN&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;BEGIN&lt;/a&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=TRANSACTION&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;TRANSACTION&lt;/a&gt;;&lt;/pre&gt;&lt;/pre&gt;&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;Ist eine Transaktion offen, können diverse SQL-Abfragen durchgeführt werden.&lt;br&gt;Gibt es hierbei keine Fehler, so kann man die Transaktion einfach wie folgt schließen.&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Transaktion schließen/bestätigen&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=COMMIT&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;COMMIT&lt;/a&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=TRANSACTION&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;TRANSACTION&lt;/a&gt;;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre&quot; class=&quot;Apple-tab-span&quot;&gt;&amp;nbsp;&lt;/span&gt;Erst mit einem COMMIT werden die ausgeführten Abfragen in der Datenbank veröffentlicht.&lt;br&gt;&lt;br&gt;Gibt es bei der Verarbeitung der beinhalteten SQL-Abfragen Probleme/Fehler, so muss die Transaktion manuell oder automatisch zurückgeschrieben werden. Dabei werden alle durchgeführten Abfragen verworfen.&lt;br&gt;&lt;br&gt;Das zurückschreiben kann wie folgt durchgeführt werden.&lt;/p&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; &lt;span style=&quot;color: #008000&quot;&gt;-- Transaktion rückgängig machen&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=ROLLBACK&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;ROLLBACK&lt;/a&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=TRANSACTION&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;TRANSACTION&lt;/a&gt;;&lt;/pre&gt;&lt;/pre&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/1031390976505115543/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/einfaches-arbeiten-mit-transaktionen.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1031390976505115543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1031390976505115543'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/einfaches-arbeiten-mit-transaktionen.html' title='Einfaches Arbeiten mit Transaktionen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-2444461794200672401</id><published>2013-03-11T19:00:00.000+01:00</published><updated>2013-03-11T22:27:13.772+01:00</updated><title type='text'>Grundlegende Änderung in diesem Blog</title><content type='html'>Wer mich kennt, weiß dass ich ursprünglich aus der Microsoft SQL-Server Administration komme.&lt;br /&gt;
In den letzten Jahren habe ich diesen Bereich etwas vernachlässigt.&lt;br /&gt;
Da mir die Verwaltung sowie die Entwicklung mit dem SQL-Server aber immer (naja eher oft ;-)) sehr viel Freude bereitet hat, möchte ich wenigstens weiterhin darüber bloggen.&lt;br /&gt;
&lt;br /&gt;
Da ich aktuell nur noch wenig gute und vor allem wirklich aktive Blogs zum Thema SQL-Server kenne, möchte ich diesen Blog wieder aktiver nutzen und vor allem das grundlegende Thema ändern.&lt;br /&gt;
&lt;br /&gt;
Es kann zwar durchaus passieren, dass noch einmal ein Post zum Thema .Net/C# rausrutscht.&lt;br /&gt;
Das Hauptthema dieses Blogs soll aber zukünftig der Microsoft SQL-Server werden.&lt;br /&gt;
&lt;br /&gt;
Hier möchte ich die Gelegenheit nutzen und noch einmal grundlegende Themen aufarbeiten um spätere Posts auch darauf aufzubauen.</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/2444461794200672401/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/grundlegende-anderung-in-diesem-blog.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/2444461794200672401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/2444461794200672401'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2013/03/grundlegende-anderung-in-diesem-blog.html' title='Grundlegende Änderung in diesem Blog'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-9190584728852254455</id><published>2012-08-10T13:42:00.001+02:00</published><updated>2012-08-10T13:42:48.579+02:00</updated><title type='text'>Entpacken einer MSI-Datei</title><content type='html'>&lt;p&gt;Wer kennt es nicht? Man benötigt mal schnell eine Datei aus einem MSI-Installationspaket (z.B. die bekannten Telerik-Controls) und möchte dieses aber nicht gleich installieren. Hierfür gibt es eine ganz einfache Lösung.&lt;br&gt;Mit dem Kommandozeilen-Programm “msiexec” kann man die Dateien eines MSI-Pakets einfach extrahieren. Dieses funktioniert ähnlich wie das Entpacken eines Zip-Archivs.&lt;/p&gt; &lt;p&gt;Der Aufruf des Programms erfolgt wie gesagt ganz einfach in der Konsole wie folgt:&lt;br&gt;msiexec /a PfadZumMSIFile /qb TARGETDIR=AusgabeVerzeichnis&lt;/p&gt; &lt;p&gt;Das Ausgabeverzeichnis wird automatisch erstellt, wenn es noch nicht vorhanden ist.&lt;br&gt;Hier mal ein Beispiel, um das Paket “C:\Downloads\RadControls_WinForms.msi” in das Verzeichnis “C:\Entwicklung” zu extrahieren.&lt;/p&gt; &lt;p&gt;msiexec /a C:\Downloads\RadControls_WinForms.msi /qb TARGETDIR=C:\Entwicklung&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/9190584728852254455/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2012/08/entpacken-einer-msi-datei.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/9190584728852254455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/9190584728852254455'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2012/08/entpacken-einer-msi-datei.html' title='Entpacken einer MSI-Datei'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-8948598921091341892</id><published>2012-04-12T12:19:00.001+02:00</published><updated>2012-04-12T12:20:58.018+02:00</updated><title type='text'>SQL-Server 2012 Editionsvergleich</title><content type='html'>Hat man mit den unterschiedlichen Editionen des SQL-Servers zu tun, kann es passieren, dass beim Transferieren einer Datenbank auf einmal bestimmte Funktionen wie zum Beispiel Replikationen oder ähnliches nicht mehr zur Verfügung stehen.&amp;nbsp;Man sollte also vor einer solchen Aktion auch immer einen Blick auf die verwendeten SQL-Server Editionen und deren Features werfen.&lt;br /&gt;
&lt;br /&gt;
Eine gute Übersicht für den neuen SQL-Server 2012 gibt es dazu auf den MSDN-Seiten unter folgendem Link:&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/cc645993(SQL.110).aspx&quot;&gt;Editionsvergleich des SQL-Servers 2012&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/8948598921091341892/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2012/04/sql-server-2012-editionsvergleich.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8948598921091341892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/8948598921091341892'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2012/04/sql-server-2012-editionsvergleich.html' title='SQL-Server 2012 Editionsvergleich'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-7252848034837775333</id><published>2011-09-02T14:23:00.001+02:00</published><updated>2011-09-02T14:23:26.514+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><title type='text'>Select Top-Rows per SQL</title><content type='html'>&lt;p&gt;Gerade brauchte ich für einen schnellen Test mal wieder einfach nur ein paar Datensätze aus einer Datenbank.&lt;br /&gt;
Die schnellste Art und Weise dieses zu realisieren ist, wenn man einfach nur die ersten x Zeilen ausliest.&lt;br /&gt;
Diese könnte man ggf. für bestimmte Auswertungen auch direkt sortiert ausgeben. Aber für meine Tests war das völlig egal.&lt;/p&gt;&lt;p&gt;Da ich ständig mit dem MS SQL-Server arbeite habe ich meine Abfrage wie folgt geschrieben.&lt;br /&gt;
&lt;div id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Rückgabe der ersten 5 Zeilen aus Tabelle1&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TOP&lt;/span&gt; 5 * &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; Tabelle1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
Bei meinem aktuellen Test habe ich jedoch eine Oracle Datenbank abgefragt.&lt;br /&gt;
Nach der Ausführung des oben stehenden SQL-Statements habe ich jedoch folgenden Fehler bekommen.&lt;br /&gt;
Error starting at line 1 in command:&lt;br /&gt;
SELECT TOP 5 * FROM Tabelle1&lt;br /&gt;
Error at Command Line:1 Column:11&lt;br /&gt;
Error report:&lt;br /&gt;
SQL Error: ORA-00923: Schlüsselwort FROM nicht an erwarteter Stelle gefunden&lt;br /&gt;
00923. 00000 -&amp;nbsp; &quot;FROM keyword not found where expected&quot;&lt;br /&gt;
*Cause:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
*Action:&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;Nach kurzer Überlegung ist es mir direkt wieder eingefallen. Oracle kennt keinen TOP-Befehl.&lt;br /&gt;
Dafür gibt es in Oracle-Datenbanken jedoch die Spalte &quot;rownum&quot;. Mit dieser kann man dann nicht nur Top-Werte sondern auch ganz bestimmte Datensätze wie folgt ausgeben lassen.&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Rückgabe der ersten 5 Zeilen aus Tabelle1&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; Tabelle1 &lt;span style=&quot;color: #0000ff&quot;&gt;WHERE&lt;/span&gt; rownum &amp;lt;= 5&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;-- Rückgabe der Zeilen 6 bis 10 aus Tabelle1&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; Tabelle1 &lt;span style=&quot;color: #0000ff&quot;&gt;WHERE&lt;/span&gt; rownum &amp;gt; 5 &lt;span style=&quot;color: #0000ff&quot;&gt;AND&lt;/span&gt; rownum &amp;lt;= 10&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/7252848034837775333/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/09/select-top-rows-per-sql.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/7252848034837775333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/7252848034837775333'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/09/select-top-rows-per-sql.html' title='Select Top-Rows per SQL'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-6800480592719190192</id><published>2011-08-11T21:25:00.001+02:00</published><updated>2011-08-12T06:47:30.122+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="EGOPhotoView"/><category scheme="http://www.blogger.com/atom/ns#" term="MonoTouch"/><title type='text'>Builderror bei MonoTouch-Projekten mit EGOPhotoViewController</title><content type='html'>In einem aktuellen MonoTouch-Projekt habe ich für die Anzeige einer Bildergalerie das kleine externe Framework EGOPhotoView/EGOPhotoViewController eingebunden. Nach der Implementierung konnte ich das Projekt nicht mehr kompilieren. Es kam im Output immer folgender Fehler:&lt;br /&gt;
&lt;br /&gt;
Undefined symbols:&lt;br /&gt;
&quot;__Unwind_Resume&quot;, referenced from:&lt;br /&gt;
+[EGOCache currentCache] in libPhotoViewerKitMobile.a(EGOCache.o)&lt;br /&gt;
-[EGOCache saveCacheDictionary] in libPhotoViewerKitMobile.a(EGOCache.o)&lt;br /&gt;
+[EGOImageLoader sharedImageLoader] in libPhotoViewerKitMobile.a(EGOImageLoader.o)&lt;br /&gt;
ld: symbol(s) not found&lt;br /&gt;
collect2: ld returned 1 exit status&lt;br /&gt;
Process exited with code 1, command:&lt;br /&gt;
&lt;br /&gt;
Abhilfe hat hier folgende Einstellung geschaffen:&lt;br /&gt;
- Projekteigenschaften öffnen&lt;br /&gt;
- Build =&gt; IPhone Build auswählen&lt;br /&gt;
- Im Reiter &quot;General&quot; die &quot;Additional mtouch arguments&quot; erweitern um -gcc_flags &quot;-cxx -lgcc_eh&quot;&lt;br /&gt;
&lt;br /&gt;
Tipp:&lt;br /&gt;
Um erweiterte Ausgabemeldungen (Output) zu bekommen, muss man einfach in die arguments noch die Parameter -v -v -v aufnehmen.</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/6800480592719190192/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/08/builderror-bei-monotouch-projekten-mit.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/6800480592719190192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/6800480592719190192'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/08/builderror-bei-monotouch-projekten-mit.html' title='Builderror bei MonoTouch-Projekten mit EGOPhotoViewController'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-3220431872116768791</id><published>2011-08-10T14:02:00.009+02:00</published><updated>2011-08-10T21:04:20.981+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQLite"/><title type='text'>Zufalls-Datensätze direkt per SQL auslesen</title><content type='html'>Manchmal benötigt man schnell und einfach einen einzelnen, beliebigen Datensatz aus einer Datenbank/Tabelle. Wo mir dieses bislang sehr nützlich erschien, war zum Beispiel beim Einlesen von Zufallsbildern auf mobilen Geräten. Um hier keinen unnötigen Overhead wie das Erstellen von Objekt-Id-Listen zu erzeugen, ist es manchmal hilfreich einfach nur einen Zufallswert direkt aus der Datenbank geliefert zu bekommen. Dieses kann man ganz einfach wie folgt realisieren.&lt;br /&gt;
&lt;br /&gt;
MS-SQL-Server:  &lt;div id=&quot;codeSnippetWrapper&quot; class=&quot;csharpcode-wrapper&quot;&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TOP&lt;/span&gt; 1 * &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; Testtabelle&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;BY&lt;/span&gt; NEWID();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;SQLite: &lt;br /&gt;
&lt;div id=&quot;codeSnippetWrapper&quot; class=&quot;csharpcode-wrapper&quot;&gt;&lt;div id=&quot;codeSnippet&quot; class=&quot;csharpcode&quot;&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; Testtabelle &lt;span style=&quot;color: #0000ff&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;BY&lt;/span&gt; RANDOM() &lt;span style=&quot;color: #0000ff&quot;&gt;LIMIT&lt;/span&gt; 1; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/3220431872116768791/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/08/zufallszahlen-per-sql-erstellen.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3220431872116768791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3220431872116768791'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/08/zufallszahlen-per-sql-erstellen.html' title='Zufalls-Datensätze direkt per SQL auslesen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-7630997944946932134</id><published>2011-07-19T15:32:00.001+02:00</published><updated>2011-07-19T15:34:39.264+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Exception"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows CE"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Windows Mobile - .Net Compact Framework Exceptions anzeigen</title><content type='html'>Bei einem aktuellen Projekt arbeite ich an einer Anwendung für ein Windows CE 5.0 Gerät. Um genau zu sein handelt es sich um einen Scanner vom Typ Casio DT-X7.&lt;br /&gt;
&lt;br /&gt;
Bei der Entwicklung habe ich festgestellt, dass meine Fehlerprotokolle (Logging der Exceptions in eine Textdatei) nicht korrekt geschrieben werden können. Und zwar wurde immer folgende Meldung protokolliert, egal welcher Fehler aufgetreten ist:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&quot;An error message is available for this exception but cannot be displayed because these messages are optional and are not currently installed on this device. Please install ‘NETCFv35.Messages.EN.wm.cab’ for Windows Mobile 5.0 and above or&amp;nbsp; ‘NETCFv35.Messages.EN.cab’ for other platforms. Restart the application to see the message.&quot;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Folglich habe ich mich, ganz wie in der Meldung beschrieben, daran gemacht die angegeben CAB zu installieren. Hierzu habe ich die folgende Datei von meinem PC (Windows Mobile SDK muss installiert sein) auf das mobile Gerät kopiert:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;C:\Programme\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\Diagnostics\NETCFv35.Messages.EN.cab&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Nach dem Kopieren habe ich die Datei auf dem mobilen Gerät gestartet und erfolgreich installiert.&lt;br /&gt;
&lt;br /&gt;
Hier gilt es zu beachten, dass es im genannten Verzeichnis auch eine Datei &quot;NETCFv35.Messages.EN.wm.cab&quot; gibt. Diese Datei ist ausschließlich für Geräte mit Windows Mobile. Die Datei ohne &quot;.wm&quot; im Namen ist für alle weiteren Systeme wie z. B. Windows CE. &lt;br /&gt;
&lt;br /&gt;
Verwendet man versehentlich die falsche Datei, so kommt eine Fehlermeldung vor der Installation wie z. B. folgende:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;The file &quot;NETCFv35.Messages.EN.wm.cab&quot; is not a valid Windows CE Setup file.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
In diesem Fall empfehle ich einfach noch einmal genau hinzuschauen und ggf. auch einmal das Bestriebssystem auf dem mobilen Gerät zu überprüfen. Manchmal hat man vielleicht doch etwas verwechselt oder übersehen.&lt;br /&gt;
&lt;br /&gt;
Wurde aber alles korrekt installiert, so sollten auch die Fehlermeldungen wieder korrekt angezeigt/protokolliert werden.&lt;br /&gt;
&lt;br /&gt;
Bei mir war dieses aber nicht der Fall. So musste ich weitersuchen.&lt;br /&gt;
Hierfür habe ich mir die kostenfreien &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=10601&quot; target=&quot;_blank&quot;&gt;Windows Mobile Power Toys&lt;/a&gt; von Microsoft installiert und mit dem MobileLogger geschaut, ob es noch irgendwelche Probleme gibt. Und ich bin direkt fündig geworden. Der Logger zeigt mir die Meldung:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&quot;Failed to load [System.SR, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC]&quot;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Das Problem hier ist, dass eine im CAB enthaltene Datei unter anderem Namen vorliegt, als sie eigentlich referenziert ist. Und zwar handelt es sich hierbei um die Datei &quot;SYCCFA~1.001&quot;. Als Referenz wird der Name &quot;System.SR&quot; erwartet. Helfen kann man sich hier ganz einfach, in dem man die CAB-Datei entpackt, die Datei in &quot;System.SR.dll&quot; umbenennt und diese anschließend im sein Windows Mobile Projekt als Referenz einbindet.&lt;br /&gt;
&lt;br /&gt;
Jetzt wurden sogar bei mir alle Fehlermeldungen korrekt ausgegeben.</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/7630997944946932134/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/windows-mobile-net-compact-framework.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/7630997944946932134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/7630997944946932134'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/windows-mobile-net-compact-framework.html' title='Windows Mobile - .Net Compact Framework Exceptions anzeigen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-3208988560962774794</id><published>2011-07-14T11:28:00.000+02:00</published><updated>2011-07-14T11:28:41.655+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="MonoTouch"/><category scheme="http://www.blogger.com/atom/ns#" term="UITextView"/><title type='text'>MonoTouch: UITextView mit zentriertem Inhalt bei der Bearbeitung</title><content type='html'>In einer IPhone-App hatte ich gerade das Problem, dass ich eine UITextView (Textbox) implementiert habe, die im Bearbeitungsmodus (nach Klick) immer den beinhalteten Text außerhalb des sichtbaren Bereichs verschoben hat. Das heißt, man musste jedes Mal scrollen um den Text zu sehen.&lt;br /&gt;
&lt;br /&gt;
So sieht das ganze dann im Einsatz aus:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAtwlTs-LNZcrHfQnd2f38NATeK8jeXkiufenqtX0EtuNIDPe5nMoYQDdhJoSUSQFh-6ENToq-PtFEjZcWQVKSyq1LFzLDjv58gwXwJaziKYX94wC95_ldwu7F0_5TBkXiVf1VEPDB5fDy/s1600/Screen+shot+2011-07-14+at+11.24.00.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;58&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAtwlTs-LNZcrHfQnd2f38NATeK8jeXkiufenqtX0EtuNIDPe5nMoYQDdhJoSUSQFh-6ENToq-PtFEjZcWQVKSyq1LFzLDjv58gwXwJaziKYX94wC95_ldwu7F0_5TBkXiVf1VEPDB5fDy/s320/Screen+shot+2011-07-14+at+11.24.00.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Dieses liegt daran, dass die UITextView standardmäßig einen unteren &quot;Rahmen&quot; von 32 Pixel einfügt. Da auch standardmäßig das Autoscrolling aktiv ist, wird immer die letzte Zeile&amp;nbsp;fokussiert. Somit rutsch der eigentlich Inhalt/Text soweit nach oben, dass er nicht mehr sichtbar ist.&lt;br /&gt;
&lt;br /&gt;
Abhilfe schafft hier die kleine Property &quot;ContentInset&quot;.&lt;br /&gt;
&lt;br /&gt;
Codebespiel:&lt;br /&gt;
UITextView textView = new UITextView(new RectangleF(10, 10, 280, 30));&lt;br /&gt;
textView.ContentInset = new UIEdgeInsets(0, 0, 0, 0);&lt;br /&gt;
&lt;br /&gt;
Und so sieht das Ganze dann mit der gesetzten Property aus:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSjo0VL7y0zzFo_GBFnpBOYbD0c8Aj6WgemNAMjJf56tAfaEw5DP4ru5UxJLIOXVADAgHhmrokNV8kQTFcqz_bqSsJ2a1Atd8qJjbLnLryCRKPlZx3OtbCXgzxjkhsEgPkq9bpuweeC5YN/s1600/Screen+shot+2011-07-14+at+11.23.23.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;58&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSjo0VL7y0zzFo_GBFnpBOYbD0c8Aj6WgemNAMjJf56tAfaEw5DP4ru5UxJLIOXVADAgHhmrokNV8kQTFcqz_bqSsJ2a1Atd8qJjbLnLryCRKPlZx3OtbCXgzxjkhsEgPkq9bpuweeC5YN/s320/Screen+shot+2011-07-14+at+11.23.23.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/3208988560962774794/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/monotouch-uitextview-mit-zentriertem.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3208988560962774794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/3208988560962774794'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/monotouch-uitextview-mit-zentriertem.html' title='MonoTouch: UITextView mit zentriertem Inhalt bei der Bearbeitung'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAtwlTs-LNZcrHfQnd2f38NATeK8jeXkiufenqtX0EtuNIDPe5nMoYQDdhJoSUSQFh-6ENToq-PtFEjZcWQVKSyq1LFzLDjv58gwXwJaziKYX94wC95_ldwu7F0_5TBkXiVf1VEPDB5fDy/s72-c/Screen+shot+2011-07-14+at+11.24.00.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-2912777988605138066</id><published>2011-07-08T22:30:00.003+02:00</published><updated>2011-07-30T23:10:02.190+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="BulkInsert"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQLite"/><title type='text'>SQLite BulkInsert-Alternative - Kleiner Code, große Wirkung</title><content type='html'>&lt;style type=&quot;text/css&quot;&gt;p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px cambria}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px cambria; min-height: 14.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px &#39;Times New Roman&#39;; min-height: 15.0px}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px monaco; min-height: 16.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px cambria; color: #ff00ff}span.s1 {font: 12.0px &#39;Times New Roman&#39;}span.s2 {color: #c1272e}span.s3 {color: #000000}span.s4 {color: #00a068}span.s5 {font: 12.0px &#39;Times New Roman&#39;; color: #ff00ff}span.s6 {color: #ff00ff}&lt;/style&gt; &lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Heute bin ich auf ein Performance-Problem beim Füllen einer SQLite Datenbank gestoßen. Und zwar nutze ich für eine mobile Anwendung eine Datenbank, welche sich täglich komplett&amp;nbsp; inhaltlich verändern kann. Diese Datenbank wird dann per REST Webservice aus einem ASP.Net Web heruntergeladen.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Die Datenbank beinhaltet zwei Tabellen mit jeweils zehn Spalten. Da es bei SQLite kein Bulk-Insert wie z.B. beim SQL-Server gibt, habe ich zuerst versucht die ca. 40.000 Datensätze nacheinander ganz einfach per INSERT einzufügen. Dieses war mir aber deutlich zu langsam, so dass ich nach optimaleren Alternativen gesucht habe. Und ich bin auch recht schnell fündig geworden. Hierfür konnte ich sogar meine bestehende Programmierung fast komplett behalten. Ich musste lediglich einen kleinen Teil umstellen und um ein paar Zeilen Code erweitern.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Hier ist erst einmal zur Übersicht der Aufbau der ersten Tabelle.&lt;/div&gt;&lt;br /&gt;
&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px&quot;&gt;&lt;pre id=&quot;codeSnippet&quot; style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; Artikel(Artikelnummer &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;(255) &lt;span style=&quot;color: #0000ff&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;KEY&lt;/span&gt; ,EAN 
&lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;(255),Artikelbezeichnung1 &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;(255),Artikelbezeichnung2 
&lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;(255),Hersteller &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;(255),EmpfVK &lt;span style=&quot;color: #0000ff&quot;&gt;FLOAT&lt;/span&gt;,Verfuegbarkeit &lt;span style=&quot;color: #0000ff&quot;&gt;INTEGER&lt;/span&gt;, 
Gewicht &lt;span style=&quot;color: #0000ff&quot;&gt;FLOAT&lt;/span&gt;, Status_NichtVerfuegbar &lt;span style=&quot;color: #0000ff&quot;&gt;BOOLEAN&lt;/span&gt;,Artikelinfo 
TEXT);&lt;/pre&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Das Befüllen der Tabelle sieht dann in meine Programmierung wie folgt aus.&lt;/div&gt;&lt;br /&gt;
&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px&quot;&gt;&lt;br /&gt;
&lt;div id=&quot;codeSnippet&quot; style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum1&quot; style=&quot;color: #606060&quot;&gt;   1:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum2&quot; style=&quot;color: #606060&quot;&gt;   2:&lt;/span&gt; SQLiteConnection connection = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum3&quot; style=&quot;color: #606060&quot;&gt;   3:&lt;/span&gt; SQLiteConnection();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum4&quot; style=&quot;color: #606060&quot;&gt;   4:&lt;/span&gt;      &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum5&quot; style=&quot;color: #606060&quot;&gt;   5:&lt;/span&gt; SQLiteCommand command = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum6&quot; style=&quot;color: #606060&quot;&gt;   6:&lt;/span&gt; SQLiteCommand(connection);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum7&quot; style=&quot;color: #606060&quot;&gt;   7:&lt;/span&gt; command.CommandText = &lt;span style=&quot;color: #006080&quot;&gt;&quot;INSERT INTO Artikel &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum8&quot; style=&quot;color: #606060&quot;&gt;   8:&lt;/span&gt; VALUES &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum9&quot; style=&quot;color: #606060&quot;&gt;   9:&lt;/span&gt; (@Artikelnummer,@EAN,@Artikelbezeichnung1,@Artikelbezeichnung2,@Hersteller,@EmpfVK,@Verfuegbarkeit,@Gewicht,@Status_NichtVerfuegbar,@Artikelinfo);&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum10&quot; style=&quot;color: #606060&quot;&gt;  10:&lt;/span&gt; command.Prepare();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum11&quot; style=&quot;color: #606060&quot;&gt;  11:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum12&quot; style=&quot;color: #606060&quot;&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum13&quot; style=&quot;color: #606060&quot;&gt;  13:&lt;/span&gt; SQLiteTransaction tr = connection.BeginTransaction();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum14&quot; style=&quot;color: #606060&quot;&gt;  14:&lt;/span&gt; command.Transaction = tr;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum15&quot; style=&quot;color: #606060&quot;&gt;  15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum16&quot; style=&quot;color: #606060&quot;&gt;  16:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum17&quot; style=&quot;color: #606060&quot;&gt;  17:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum18&quot; style=&quot;color: #606060&quot;&gt;  18:&lt;/span&gt; i = 0; i &amp;lt; listArtikel.Count; i++)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum19&quot; style=&quot;color: #606060&quot;&gt;  19:&lt;/span&gt; {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum20&quot; style=&quot;color: #606060&quot;&gt;  20:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Artikelnummer&quot;&lt;/span&gt;, listArtikel[i].Artikelnummer));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum21&quot; style=&quot;color: #606060&quot;&gt;  21:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@EAN&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum22&quot; style=&quot;color: #606060&quot;&gt;  22:&lt;/span&gt; listArtikel[i].EAN));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum23&quot; style=&quot;color: #606060&quot;&gt;  23:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Artikelbezeichnung1&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum24&quot; style=&quot;color: #606060&quot;&gt;  24:&lt;/span&gt; listArtikel[i].Artikelbezeichnung1));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum25&quot; style=&quot;color: #606060&quot;&gt;  25:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Artikelbezeichnung2&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum26&quot; style=&quot;color: #606060&quot;&gt;  26:&lt;/span&gt; listArtikel[i].Artikelbezeichnung2));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum27&quot; style=&quot;color: #606060&quot;&gt;  27:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Hersteller&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum28&quot; style=&quot;color: #606060&quot;&gt;  28:&lt;/span&gt; listArtikel[i].Hersteller));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum29&quot; style=&quot;color: #606060&quot;&gt;  29:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@EmpfVK&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum30&quot; style=&quot;color: #606060&quot;&gt;  30:&lt;/span&gt; listArtikel[i].EmpfVK));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum31&quot; style=&quot;color: #606060&quot;&gt;  31:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Verfuegbarkeit&quot;&lt;/span&gt;, listArtikel[i].Verfuegbarkeit));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum32&quot; style=&quot;color: #606060&quot;&gt;  32:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Gewicht&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum33&quot; style=&quot;color: #606060&quot;&gt;  33:&lt;/span&gt; listArtikel[i].Gewicht));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum34&quot; style=&quot;color: #606060&quot;&gt;  34:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Status_NichtVerfuegbar&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum35&quot; style=&quot;color: #606060&quot;&gt;  35:&lt;/span&gt; listArtikel[i].Status_NichtVerfuegbar));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum36&quot; style=&quot;color: #606060&quot;&gt;  36:&lt;/span&gt;   command.Parameters.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SQLiteParameter(&lt;span style=&quot;color: #006080&quot;&gt;&quot;@Artikelinfo&quot;&lt;/span&gt;, &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum37&quot; style=&quot;color: #606060&quot;&gt;  37:&lt;/span&gt; listArtikel[i].Artikelinfo));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum38&quot; style=&quot;color: #606060&quot;&gt;  38:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum39&quot; style=&quot;color: #606060&quot;&gt;  39:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum40&quot; style=&quot;color: #606060&quot;&gt;  40:&lt;/span&gt;   command.ExecuteNonQuery();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum41&quot; style=&quot;color: #606060&quot;&gt;  41:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum42&quot; style=&quot;color: #606060&quot;&gt;  42:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum43&quot; style=&quot;color: #606060&quot;&gt;  43:&lt;/span&gt;   command.Parameters.Clear();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum44&quot; style=&quot;color: #606060&quot;&gt;  44:&lt;/span&gt; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum45&quot; style=&quot;color: #606060&quot;&gt;  45:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum46&quot; style=&quot;color: #606060&quot;&gt;  46:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum47&quot; style=&quot;color: #606060&quot;&gt;  47:&lt;/span&gt; tr.Commit();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none&quot;&gt;&lt;span id=&quot;lnum48&quot; style=&quot;color: #606060&quot;&gt;  48:&lt;/span&gt; command.Dispose();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Das Wichtigste an dieser Programmierung ist, dass sich die Parameter-Zuweisung sowie die Ausführung (ExecuteNonQuery) innerhalb der gestarteten Transaktion liegt. Außerdem sollte das eigentliche SQL-Statement (Command.Text) außerhalb der Schleife und nicht bei jedem Durchlauf zugewiesen werden. &lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Ein weiterer wichtiger Punkt ist das Aufbereiten des SQL-Statements mit command.Prepare().&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Mir hat die Implementierung der Transaktion eine Zeitersparnis von fast 90% gebracht. Ich denke das ist ein sehr erstaunliches Ergebnis.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/2912777988605138066/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/sqlite-bulkinsert-alternative-kleiner.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/2912777988605138066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/2912777988605138066'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/sqlite-bulkinsert-alternative-kleiner.html' title='SQLite BulkInsert-Alternative - Kleiner Code, große Wirkung'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-5539956858146682880</id><published>2011-07-02T13:15:00.003+02:00</published><updated>2011-07-02T13:18:01.167+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Base64"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Base64-Strings encodieren und decodieren</title><content type='html'>Gerade wenn man Web-Applikationen entwickelt und mit Datenübertragungen zu tun hat, wird man regelmäßig mit sogenannten Base64-Strings konfrontiert. Wenn man dieses zum ersten Mal hört, fragt man sich wahrscheinlich, was das eigentlich ist.&lt;br /&gt;
Dabei ist das alles eigentlich ganz einfach. Base64 ist eine Kodierung für 8-Bit-Binärdaten wie zum Beispiel Bilder, PDF-Dokumente oder Zip-Archive. Bei einer Base64-Kodierung werden die Binärdaten zum Beispiel eines Bildes in einen lesbaren ACII-String umgewandelt. Daher ist auch oft die Rede von einem Base64-String. Erkennen kann man eine solche Zeichenkette daran, dass keine Sonderzeichen außer &quot;+&quot;, &quot;/&quot; und &quot;=&quot; vorhanden sind und der String immer mit einem &quot;=&quot;-Zeichen endet.&lt;br /&gt;
&lt;br /&gt;
Setzt man das ganze nun in der Programmierung (C# / .Net) um, könnte es wie folgt aussehen.&lt;br /&gt;
&lt;br /&gt;
Daten encodieren / String in Base64-String umwandeln&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;public string base64Encode(string dataToEncode)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;// Übergebenen String in ein ByteArray umwandeln&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;byte[] bytesToEncode = System.Text.Encoding.UTF8.GetBytes(dataToEncode);&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;// Erstelltes ByteArray in einen Base64 kodierten String umwandeln und zurückgeben&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;return Convert.ToBase64String(bytesToEncode);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;Daten decodieren / Base64-String in String umwandeln&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;public string base64Decode(string dataToDecode)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;// Ein Objekt der Klasse ASCIIEncoding instanziieren&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;// Übergebenen String in ein ByteArray umwandeln&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;byte[] bytesToDecode = Convert.FromBase64String(dataToDecode);&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;// Erstelltes ByteArray aus dem Base64-String in einen decodierten (nicht kodierten) String umwandeln und zurückgeben&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;return encoding.GetString(bytesToDecode);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/5539956858146682880/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/base64-strings-encodieren-und.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5539956858146682880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5539956858146682880'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/07/base64-strings-encodieren-und.html' title='Base64-Strings encodieren und decodieren'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-1429756272499334030</id><published>2011-06-30T20:43:00.000+02:00</published><updated>2011-06-30T20:43:31.889+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL-Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Verbindungsserver"/><title type='text'>Microsoft SQL-Server Verbindungsserver einrichten</title><content type='html'>&lt;div class=&quot;p1&quot;&gt;Mit folgendem, simplen SQL-Statement würde man Daten der Tabelle &quot;Maschinen&quot; aus der Datenbank &quot;FlorianTestDB&quot; von einem Server &quot;Testserver2&quot; auf einen anderen Server &quot;Testserver1&quot; in die gleichnamige Datenbank/Tabelle kopieren.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;INSERT INTO&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: magenta;&quot;&gt;[Testserver1].[FlorianTestDB].[dbo].[Maschinen]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;SELECT * FROM&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: magenta;&quot;&gt;[Testserver2].[FlorianTestDB].[dbo].[Maschinen]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Voraussetzung für eine erfolgreiche Übertragung ist, dass der Zielserver als sogenannter Verbindungsserver auf dem Quellserver eingerichtet ist. Ist dieses nicht der Fall, so kommt folgende Meldung.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Meldung 7202, Ebene 11, Status 2, Zeile 1&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Server &#39;Testserver1&#39; konnte in &#39;sys.servers&#39; nicht gefunden werden. Stellen Sie sicher, dass der richtige Servername angegeben wurde. Führen Sie ggf. die gespeicherte Prozedur &#39;sp_addlinkedserver&#39; aus, um den Server in &#39;sys.servers&#39; hinzuzufügen.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Abhilfe schafft man, indem man den Verbindungsserver auf einfache Art und Weise&amp;nbsp; anlegt. Hierzu muss man eine Verbindung mit dem Quellserver herstellen und folgenden Befehl ausführen, um den Zielserver als Verbindungsserver einzurichten.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;EXEC&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;sp_addlinkedserver&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: magenta;&quot;&gt;&#39;Testserver1&#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Als Ergebnis sollte folgendes zurückkommen.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Befehl(e) wurde(n) erfolgreich abgeschlossen.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Führt man das SQL-Statement zum Kopieren der Daten nun erneut aus, so sollte es erfolgreich ausgeführt werden.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Eine kleine Einschränkung hierbei gibt es jedoch. Fügt man den Verbindungsserver wie oben beschrieben hinzu, so ist es notwendig, dass auf beiden Servern der aktuell verwendete Benutzer identisch eingerichtet ist.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Möchte man dieses nicht, benutzt unterschiedliche Passwörter oder verschiedene Benutzer, so ist es am einfachsten den Verbindungsserver über das SQL-Server-Management-Studio anzulegen.&lt;br /&gt;
&lt;br /&gt;
Diese Vorgehensweise geht für die SQL-Server-Versionen 2000, 2005 und 2008&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/1429756272499334030/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/microsoft-sql-server-verbindungsserver.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1429756272499334030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/1429756272499334030'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/microsoft-sql-server-verbindungsserver.html' title='Microsoft SQL-Server Verbindungsserver einrichten'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-5589834807429664849</id><published>2011-06-28T22:23:00.002+02:00</published><updated>2011-06-30T20:58:32.486+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="REST"/><category scheme="http://www.blogger.com/atom/ns#" term="Webservice"/><title type='text'>Dateidownload via REST-Webservice</title><content type='html'>REST ist ein Akronym für Representational State Transfer. Einfach gesagt steht REST für eine Art der Datenübertragung per HTTP. &amp;nbsp;Unterhalb von REST gibt es noch eine weitere Unterscheidung je nach Befehlstyp. Hier gibt es folgende Möglichkeiten:&lt;br /&gt;
&lt;br /&gt;
- GET (Download von Dateien)&lt;br /&gt;
- POST (Upload von Dateien)&lt;br /&gt;
- PUT (Upload von Dateien)&lt;br /&gt;
- DELETE (Löschen von Dateien)&lt;br /&gt;
&lt;br /&gt;
Im folgenden Beispiel zeige ich, wie man einen einfachen Datei-Download anhand eines REST-Webservices (per GET) erstellen kann.&lt;br /&gt;
&lt;br /&gt;
Bei &quot;context&quot; handelt es sich um den aktuellen HttpContext.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;//&lt;/span&gt; Prüfen der Http-Übertragungsmethode&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #cc0000;&quot;&gt;if&lt;/span&gt;(context.Request.HttpMethod = &lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;GET&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; FileInfo-Objekt für die Datei erstellen, die heruntergeladen werden soll&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp; &amp;nbsp; FileInfo requestFile = &lt;span class=&quot;s2&quot; style=&quot;color: #cc0000;&quot;&gt;new&lt;/span&gt; FileInfo(&lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;C:\\Testdatei.txt&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #4500ff;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Anhand der gerade ermittelten Datei ein ByteArray für eine Datenübertragung erstellen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;byte&lt;/span&gt;[] fileBytes = File.ReadAllBytes(requestFile.FullName);&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Aktuellen Inhalt des HttpContextes leeren&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.Clear();&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Aktuelle Headerinformationen des HttpContextes leeren&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.ClearHeaders();&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Angabe des Types der zu übertragenden Datei&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.ContentType = &lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;text/plain&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Neue Headerinformationen zum HttpContext hinzufügen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.AddHeader(&lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;Content-Disposition&quot;&lt;/span&gt;, &lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;attachment; filename=\&quot;&quot;&lt;/span&gt; + requestFile.Name + &lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;\&quot;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp; &amp;nbsp; context.Response.AddHeader(&lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;Content-Length&quot;&lt;/span&gt;, requestFile.Length.ToString());&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; MD5-Hash für aktuelle Datei erstellen um nach dem Download die Vollständigkeit zu prüfen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; //&lt;/span&gt; Info: FileHelper ist eine eigene Hilfs-Klasse zum erstellen des MD5-Hash (siehe ältere Blogposts)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.AddHeader(&lt;span class=&quot;s3&quot; style=&quot;color: magenta;&quot;&gt;&quot;Content-MD5&quot;&lt;/span&gt;, StringHelper.Base64Encode(FileHelper.GetMD5Hash(requestFile.FullName)));&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Die Datei/ByteArray ausgeben bzw. zum Download anbieten&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.OutputStream.Write(fileBytes, &lt;span class=&quot;s3&quot; style=&quot;background-color: white; color: magenta;&quot;&gt;0&lt;/span&gt;, fileBytes.Length);&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; //&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; HttpResponse wieder freigeben&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt; context.Response.Flush();&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; HttpResponse beenden&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;context.Response.End();&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;}&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/5589834807429664849/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/dateidownload-via-rest-webservice.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5589834807429664849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/5589834807429664849'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/dateidownload-via-rest-webservice.html' title='Dateidownload via REST-Webservice'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-4374489923873906703</id><published>2011-06-27T20:51:00.001+02:00</published><updated>2011-06-27T20:53:36.566+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="MD5"/><title type='text'>MD5-Hash einer Datei erstellen</title><content type='html'>Wenn man mit Dateien arbeitet speziell im Bereich Download/Upload, muss man immer wieder Dateien auf Vollständigkeit prüfen. Dieses kann man am besten über einen MD5-Hash machen.&lt;br /&gt;
Erstellt man einen MD5-Hash der Ursprungsdatei kann man diesen mit dem der neu erstellten Datei vergleichen um zu prüfen, ob die Dateien übereinstimmen. Ist das nicht der Fall, so ist beim Download/Upload etwas schief gelaufen.&lt;br /&gt;
&lt;br /&gt;
Einen MD5-Hash kann man ganz einfach wie folgt erstellen.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;//&lt;/span&gt; Gibt einen MD5-Hash-String für eine Datei zurück&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s3&quot; style=&quot;color: #cc0000;&quot;&gt;public static&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;color: #6aa84f;&quot;&gt;string&lt;/span&gt; GetMd5HashString(&lt;span class=&quot;s4&quot; style=&quot;color: #6aa84f;&quot;&gt;string&lt;/span&gt; filePath)&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Datei in neues FileStream-Objekt einlesen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;FileStream fileStream = &lt;span class=&quot;s3&quot; style=&quot;color: #cc0000;&quot;&gt;new&lt;/span&gt; FileStream(filePath, FileMode.Open);&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; Neues Objekt für MD5-Kryptographi-Provider erstellen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;MD5 md5 = &lt;span class=&quot;s3&quot; style=&quot;color: #cc0000;&quot;&gt;new&lt;/span&gt; MD5CryptoServiceProvider();&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; ByteArray mit MD5-Hash der eingelesenen Datei erstellen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;[] fileHash = md5.ComputeHash(fileStream);&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; FileStream mit eingelesener Datei wieder schließen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;fileStream.Close();&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; StringBuilder-Objekt erstellen um anschließend den MD5-Hash als String zu speichern&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;StringBuilder sb = &lt;span class=&quot;s3&quot;&gt;new&lt;/span&gt; StringBuilder();&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; MD5-Hash (ByteArray) byteweise verarbeiten und an StringBuilder anhängen&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;for&lt;/span&gt;&lt;/span&gt; (&lt;span class=&quot;s4&quot; style=&quot;color: #6aa84f;&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;s5&quot; style=&quot;color: magenta;&quot;&gt;0&lt;/span&gt;; i &amp;lt; fileHash.Length; i++)&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append(fileHash[i].ToString(&lt;span class=&quot;s5&quot;&gt;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: magenta;&quot;&gt;x2&lt;/span&gt;&quot;&lt;/span&gt;));&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt; MD5-Hash als String ausgeben&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;return&lt;/span&gt;&lt;/span&gt; sb.ToString();&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;}&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/4374489923873906703/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/md5-hash-einer-datei-erstellen.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/4374489923873906703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/4374489923873906703'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/md5-hash-einer-datei-erstellen.html' title='MD5-Hash einer Datei erstellen'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6430580789303964192.post-396944437751567066</id><published>2011-06-24T19:42:00.000+02:00</published><updated>2011-06-24T19:42:46.328+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows CE"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Installierte Versionen des .Net-Framework ermitteln unter Windows Mobile</title><content type='html'>Heute hatte ich das Problem, dass ich eine kleine Testanwendung schreiben wollte die auf einem Windows Mobile und einem Windows CE Gerät laufen sollte. Einzige Voraussetzung war, dass kein neues .Net Framework bzw. Compact Framework installiert werden darf.&lt;br /&gt;
&lt;br /&gt;
Da es sich bei dem einen Gerät um das Betriebssystem Windows CE 5.0 handelt, kommen für die Entwicklung erst einmal 2 Framework-Versionen in Frage. Und zwar hat die Version 5.0 standardmäßig das .Net-Framework 1.0 installiert. Handelt es sich jedoch um die Version 5.0 mit installiertem Service Pack 2, so ist auch das .Net-Framework 2.0 eingerichtet.&lt;br /&gt;
&lt;br /&gt;
Wie bekommt man nur einfach raus, welches das aktuell höchste, vorhandene .Net-Framework ist.&lt;br /&gt;
Hierzu gibt es eigentlich zwei ganz einfache Methoden.&lt;br /&gt;
&lt;br /&gt;
1. Im Windows-Verzeichnis befindet sich eine Datei mit dem Namen &quot;cgacutil.exe&quot;. Wenn man diese einfach ausführt, bekommt man alle installierten .Net-Frameworks, sortiert von alt nach neu, aufgelistet.&lt;br /&gt;
Der letzte Eintrag ist also die höchste installierte Version.&lt;br /&gt;
&lt;br /&gt;
2. Sollte die unter Punkt 1 beschriebene Datei aus irgendwelchen Gründen nicht aufrufbar sein, so kann man sich auch einen Registry-Editor zur Hilfe ziehen. Diesen installiert man auf dem PC und greift von dort aus auf das angeschlossene mobile Gerät zu.&lt;br /&gt;
Aus dem Editor geht man dann in der Registry unter folgenden Eintrag:&lt;br /&gt;
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP&lt;br /&gt;
Hier werden alle installierten Versionen des .Net-Frameworks in Unterverzeichnissen aufgelistet.</content><link rel='replies' type='application/atom+xml' href='http://schnorchlie.blogspot.com/feeds/396944437751567066/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/installierte-versionen-des-net.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/396944437751567066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6430580789303964192/posts/default/396944437751567066'/><link rel='alternate' type='text/html' href='http://schnorchlie.blogspot.com/2011/06/installierte-versionen-des-net.html' title='Installierte Versionen des .Net-Framework ermitteln unter Windows Mobile'/><author><name>Florian Nolte</name><uri>http://www.blogger.com/profile/12568760107084656732</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMJqmn0TbkislwITG5lO35iC6elsQr0MGHCajAssclImobkalXkmb9KE9t3AetA5z1kWcmK_5KYvGs9s4EXRQrfgglwDiiimkm9TLtu-JQRZR7Qn0uqdyqRcuThWpFtEg/s113/Profilbild_FlorianNolte.jpg'/></author><thr:total>0</thr:total></entry></feed>