<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'SQL Server 2008', 'Visual Studio 2008', and 'Visual Studio 2005'</title><link>http://bloggingabout.net/search/SearchResults.aspx?a=1&amp;o=DateDescending&amp;tag=SQL+Server+2008,Visual+Studio+2008,Visual+Studio+2005&amp;orTags=0</link><description>Search results matching tags 'SQL Server 2008', 'Visual Studio 2008', and 'Visual Studio 2005'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>System.Transactions still not working</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/06/28/system-transactions-still-not-working.aspx</link><pubDate>Thu, 28 Jun 2007 13:25:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:283402</guid><dc:creator>Dennis van der Stelt</dc:creator><description>&lt;p&gt;&lt;strong&gt;UPDATE : It seems the SQL team actually have &lt;a class="" href="http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx"&gt;build a solution&lt;/a&gt;.&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A while ago I wrote some articles on System.Transactions and the fact that &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/03/20/11748.aspx"&gt;it&amp;#39;s almost impossible to use the Lightweight Transaction Manager&lt;/a&gt; (LTM) and not get bumped up&amp;nbsp;to a distributed transaction&amp;nbsp;and use MSDTC.&lt;/p&gt;
&lt;p&gt;When you look at the sourcecode it&amp;#39;s easy to see what&amp;#39;s happening&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open a connection to MyServer with &lt;em&gt;using&lt;/em&gt; keyword&lt;/li&gt;
&lt;li&gt;Execute an insert statement to TestTable&lt;/li&gt;
&lt;li&gt;Close &lt;em&gt;using&lt;/em&gt;, but the connection stays open in the background to reply to ready-to-commit question.&lt;/li&gt;
&lt;li&gt;Open a new connection to MyServer with &lt;em&gt;using&lt;/em&gt; keyword&lt;/li&gt;
&lt;li&gt;We&amp;#39;re already using a distributed transaction&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="BORDER-RIGHT:#cccccc 1pt solid;PADDING-RIGHT:1pt;BORDER-TOP:#cccccc 1pt solid;PADDING-LEFT:1pt;FONT-SIZE:10pt;BACKGROUND:#f5f5f5;PADDING-BOTTOM:1pt;OVERFLOW:auto;BORDER-LEFT:#cccccc 1pt solid;WIDTH:100%;COLOR:black;PADDING-TOP:1pt;BORDER-BOTTOM:#cccccc 1pt solid;FONT-FAMILY:lucida console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; ConnectionString = &lt;span style="COLOR:#a31515;"&gt;@&amp;quot;Data Source=MyServer;Initial Catalog=Test;Integrated Security=SSPi;&amp;quot;&lt;/span&gt;;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; (&lt;span style="COLOR:#2b91af;"&gt;TransactionScope&lt;/span&gt; scope = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;TransactionScope&lt;/span&gt;())&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; (&lt;span style="COLOR:#2b91af;"&gt;SqlConnection&lt;/span&gt; conn1 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;SqlConnection&lt;/span&gt;(ConnectionString))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;SqlCommand&lt;/span&gt; cmd1 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;insert into TestTable([value]) Values (&amp;#39;This creates a new row&amp;#39;)&amp;quot;&lt;/span&gt;, conn1);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; conn1.Open();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; cmd1.ExecuteNonQuery();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;DistributedID : {0}&amp;quot;&lt;/span&gt;, System.Transactions.&lt;span style="COLOR:#2b91af;"&gt;Transaction&lt;/span&gt;.Current.TransactionInformation.DistributedIdentifier);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; (&lt;span style="COLOR:#2b91af;"&gt;SqlConnection&lt;/span&gt; conn2 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;SqlConnection&lt;/span&gt;(ConnectionString))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;SqlCommand&lt;/span&gt; cmd2 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;insert into TestTable([value]) Values (&amp;#39;This creates a new row&amp;#39;)&amp;quot;&lt;/span&gt;, conn2);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; conn2.Open(); &lt;span style="COLOR:green;"&gt;// Promotion to MSDTC occurs!&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; cmd2.ExecuteNonQuery();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;DistributedID : {0}&amp;quot;&lt;/span&gt;, System.Transactions.&lt;span style="COLOR:#2b91af;"&gt;Transaction&lt;/span&gt;.Current.TransactionInformation.DistributedIdentifier);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you look at &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=626675&amp;amp;SiteID=1"&gt;this thread&lt;/a&gt;&amp;nbsp;on MSDN Forums, Pablo Castro said that it&amp;#39;s a server-side (SQL Server) fix. Florin Lazar replies that this issue will likely not be addressed in Visual Studio Orcas (VS2008 by now).&lt;/p&gt;
&lt;p&gt;Florin is right, &lt;strong&gt;&lt;font color="#ff0000"&gt;it still doesn&amp;#39;t work in Visual Studio 2008&lt;/font&gt;&lt;/strong&gt;.&lt;br /&gt;Even worse, &lt;strong&gt;&lt;font color="#ff0000"&gt;it&amp;#39;s also not addressed in SQL Server 2008&lt;/font&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update : Or is &lt;/strong&gt;&lt;a class="" href="http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx"&gt;&lt;strong&gt;this the solution&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; we&amp;#39;ve been waiting for?&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So my question is, when is Microsoft going to address this issue?! When will System.Transactions work like it&amp;#39;s supposed to?&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:187b2f72-3065-49e1-8c66-f53efaa5ca10" style="PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;PADDING-BOTTOM:0px;MARGIN:0px;PADDING-TOP:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/Visual%20Studio%202008" rel="tag"&gt;Visual Studio 2008&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Orcas" rel="tag"&gt;Orcas&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SQL%20Server%202008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SQL%20Server%202005" rel="tag"&gt;SQL Server 2005&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Transactions" rel="tag"&gt;Transactions&lt;/a&gt;&lt;/div&gt;</description></item></channel></rss>