<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.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>ASP.NET Developer Notes</title><link>http://weblogs.asp.net/ryangaraygay/default.aspx</link><description>Ryan Garaygay's ASP.NET notes online</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Ancestor and Descendant IDs/info list using Common Table Expressions</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/07/12/ancestor-and-descendant-ids-info-list-using-common-table-expressions.aspx</link><pubDate>Fri, 11 Jul 2008 20:24:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6390077</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6390077</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/07/12/ancestor-and-descendant-ids-info-list-using-common-table-expressions.aspx#comments</comments><description>&lt;p&gt;
Needed some TSQL code again to retrieve descendant and ancestor entries
in a self-referencing table. I've done this a couple of times already
and although I can write it from the top of my head, sometimes you just want to
make life easier and have a script you can just modify a bit to fit the
new requirement. &lt;span id="continue"&gt;&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
So what I usually use for recursions in SQL Server 2005 are Common
Table Expressions (the "WITH" keyword). This is only available in SQL
2005 and very easy/efficient for recursive.
&lt;/p&gt;&lt;p&gt;This is definitely in BOL and articles all over nevertheless here's my basic script to get "Descendants and Self"
and "Ancestors and Self" information. In this case I only involved the
ID, ParentID, and Sequence but you may add more columns (ID and
ParentID are required to work). Also you might want to just retrieve
the ID and just perform a JOIN afterwards. &lt;/p&gt;&lt;p&gt;Please read full article from &lt;a href="http://ryangaraygay.com/blog/post/2008/07/get-ancestor-and-descendant-ids-or-info-using-sql-2005-common-table-expressions.aspx" title="Ancestor and Descendant IDs or info using SQL 2005 Common Table Expressions" mce_href="http://ryangaraygay.com/blog/post/2008/07/get-ancestor-and-descendant-ids-or-info-using-sql-2005-common-table-expressions.aspx"&gt;.NET Developer Notes on Ancestor and Descendant IDs/info using Common Table Expressions&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6390077" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/sql+server/default.aspx">sql server</category></item><item><title>Sys.ArgumentException: Value must not be null for Controls and Behaviors</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/06/25/sys-argumentexception-value-must-not-be-null-for-controls-and-behaviors.aspx</link><pubDate>Tue, 24 Jun 2008 17:01:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6315273</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6315273</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/06/25/sys-argumentexception-value-must-not-be-null-for-controls-and-behaviors.aspx#comments</comments><description>&lt;p&gt;
I was going thru some pages for my current project today when I ran into the said error "&lt;strong&gt;Sys.ArgumentException: Value must not be null for Controls and Behaviors&lt;/strong&gt;". It was the first time I've encountered it and since it was working the last time I browsed it I didn't have a clue what was causing it so had to dig around. [more]
&lt;/p&gt;
&lt;p&gt;
I have tested the page though I have to admit that not thoroughly (yeah I know, don't check in not well tested code) and there was no automated UI tests for it, took me sometime to stop the cause. I had to consider what applications I installed on my machine recently or other changes.
&lt;/p&gt;
&lt;p&gt;
After some digging it turns out that it is related to a &lt;strong&gt;modalPopupExtender &lt;/strong&gt;(part of &lt;strong&gt;AJAXControlToolkit&lt;/strong&gt;)&lt;strong&gt; &lt;/strong&gt;in the page. 
&lt;/p&gt;
&lt;p&gt;
Moving on, the extender's &lt;strong&gt;TargetControlID &lt;/strong&gt;was set to let's say "linkAddItem" control.
&lt;/p&gt;
&lt;p&gt;
Now, the catch is that recently I added an inline condition (ok, not really sure what is the right term for this but something like the one below):
&lt;/p&gt;
&lt;p&gt;
&amp;lt;% if(MyCondition) { %&amp;gt;
&lt;/p&gt;
&lt;p&gt;
&amp;lt;asp:LinkButton ID="linkAddItem" (definition here.... plus some other text)&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;lt;% } %&amp;gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So as you might have guessed, the page was looking for "linkAddItem" but in case MyCondition is true, it would not be rendered thus causing the error. I had read somewhere that if you have the TargetControl's (eg. linkAddItem) Visible attribute equals to "false", the AJAX control toolkit code would be able to detect with no problems. But not this one. The "Valu" mentioned in the error is likely the TargetControlID or at least related to it. You could verify by debugging the client script if this wouldn't solve the problem but fortunately enough not to go that far. 
&lt;/p&gt;
&lt;p&gt;
To cut this short story even shorter, my work-around was to instead have that block wrapped inside a panel (&amp;lt;asp:Panel...) and on Page PreRender, set the Panel.Visible = MyCondition. To simplify you could set just the control (eg. linkAddItem) Visibility but since there are other controls in that block, in my case the panel would be good.
&lt;/p&gt;
&lt;p&gt;
I believe you can also set Visible='&amp;lt;%= MyCondition %&amp;gt;' of the panel in the ASPX page rather than at runtime/code for as long as you have the Page databound. : this.DataBind(); (but be careful, this is recursive and would rebind all other controls in your page you have bound previously).
&lt;/p&gt;
&lt;p&gt;
Next time you run into this error, it is likely that one of the possible suspect is control visibility.&lt;/p&gt;&lt;p&gt;Cross post from &lt;a href="http://ryangaraygay.com/blog/post/2008/06/SysArgumentException-Value-must-not-be-null-for-Controls-and-Behaviors.aspx" title=".NET Developer Notes on SysArgumentException: Value must not be null for Controls and Behaviors" mce_href="http://ryangaraygay.com/blog/post/2008/06/SysArgumentException-Value-must-not-be-null-for-Controls-and-Behaviors.aspx"&gt;.NET Developer Notes&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6315273" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/aspp.net/default.aspx">aspp.net</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/atlas/default.aspx">atlas</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/ajax/default.aspx">ajax</category></item><item><title>Recent SQL Injection Attacks on ASP sites</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/05/25/recent-sql-injection-attacks-on-asp-sites.aspx</link><pubDate>Sat, 24 May 2008 16:54:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6218038</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6218038</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/05/25/recent-sql-injection-attacks-on-asp-sites.aspx#comments</comments><description>&lt;p&gt;
There seems to be a number of SQL injection attacks happening lately involving adding of &lt;b&gt;&amp;lt;script src=http://www.banner82.org/b.js&amp;gt;&amp;lt;/script&amp;gt;&lt;/b&gt;, &lt;b&gt;adword71.com/b.js&lt;/b&gt;
(and the likes&amp;nbsp;) to entries under string/text/varchar columns in the
database targetting ASP (classic/3.0) sites and SQL Server. Note, they
need not know your table or column names to mess up with you. &lt;/p&gt;&lt;p&gt;

I definitely do not wish to play cops and robbers here but I wish to
contribute a little on this. There are a number of articles on this
(read along) and even more for preventing
SQL injection and other related exploits such as cross-site scripting
so help yourself. &lt;/p&gt;&lt;p&gt;As mentioned this is more targeted to ASP (classic/3.0) sites but posting nevertheless.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Read full article from &lt;a href="http://ryangaraygay.com/blog/post/2008/05/SQL-injection-attacks-banner82-script.aspx" mce_href="http://ryangaraygay.com/blog/post/2008/05/SQL-injection-attacks-banner82-script.aspx"&gt;Security alert : SQL injection attacks - banner82 script&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Thanks to &lt;a href="http://weblogs.asp.net/rrobbins/archive/2008/05/23/sql-injection-threat-on-the-rise.aspx" target="_blank" mce_href="http://weblogs.asp.net/rrobbins/archive/2008/05/23/sql-injection-threat-on-the-rise.aspx"&gt;Robert Robbins post on rising SQL injection threats&lt;/a&gt; for making me think of cross posting here in weblogs.asp.net. I agree that this threat could be eliminated better with help/information from the community (if not MSFT itself)&lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6218038" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/asp/default.aspx">asp</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/security/default.aspx">security</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/sql+server/default.aspx">sql server</category></item><item><title>Updating ASP cookie from ASP.NET (vice versa)</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/05/20/updating-asp-cookie-from-asp-net-vice-versa.aspx</link><pubDate>Tue, 20 May 2008 11:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6203814</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6203814</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/05/20/updating-asp-cookie-from-asp-net-vice-versa.aspx#comments</comments><description>&lt;p&gt;
You might encounter a case where &lt;strong&gt;updating an ASP (classic/3.0) cookie from ASP.NET code (or vice versa) doesn't work&lt;/strong&gt;. That is despite updating the cookie value, the old value still remains.  
&lt;/p&gt;
&lt;p&gt;
I was working on a having an ASP page communicate some information to
an ASP.NET (2.0) page and vice versa and since the information was not
that critical/confidential a cookie would do (** for
critical information, it is usually done using a common
datastore/database or session though that not secure. will not discuss
here for now). I expect it to be seamless since they're accessing the
same set of cookies after all. However to my surprise it was acting
weird.
&lt;/p&gt;
&lt;p&gt;After a review of some code and I was certain that each of them
updates the cookie correctly, it was time to bring up fiddler (or any
cookie viewer) and it's when I started getting more clues.&lt;/p&gt;&lt;p&gt;Turns out that the case is actually not "not being updated" but rather a new cookie is created with the same key because of differences in handling cookie paths which must be the same across ASP and ASP.NET for them to talk about the same cookie (using the same name).&lt;/p&gt;&lt;p&gt;Read full article in the following link : &lt;a href="http://ryangaraygay.com/blog/post/2008/05/Updating-ASP-cookie-from-ASPNET-vice-versa.aspx" mce_href="http://ryangaraygay.com/blog/post/2008/05/Updating-ASP-cookie-from-ASPNET-vice-versa.aspx"&gt;Updating ASP cookie from ASP.NET (vice versa)&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6203814" width="1" height="1"&gt;</description></item><item><title>Button doesn't postback after clicking Back Button in Firefox</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/05/10/button-doesn-t-postback-after-clicking-back-button-in-firefox.aspx</link><pubDate>Fri, 09 May 2008 18:20:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6174215</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6174215</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/05/10/button-doesn-t-postback-after-clicking-back-button-in-firefox.aspx#comments</comments><description>&lt;p&gt;
I ran into this behavior (which I think is weird) where a button no longer posts back to ther server after I click on a the Firefox's back button.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
I'm not sure if I'm missing some incorrect settings whatsoever but it works on IE7.&amp;nbsp; I'm hoping someone who runs into this might verify or some thoughts on why is behaves that way. Using Firefox 2.0.0.14, ASP.NET 2.0
&lt;/p&gt;
&lt;p&gt;
Here is my code
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;ASPX &lt;/strong&gt;(sorry no formatting but it's just a simple page with an ASP button)&lt;strong&gt;&lt;br&gt;
&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;lt;%@ Page AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Language="C#" %&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br&gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br&gt;
&amp;lt;head id="Head1" runat="server"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br&gt;
&amp;lt;/head&amp;gt;&lt;br&gt;
&amp;lt;body&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" UseSubmitBehavior="false" /&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br&gt;
&amp;lt;/body&amp;gt;&lt;br&gt;
&amp;lt;/html&amp;gt;&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Code behind&lt;/strong&gt;
&lt;/p&gt;
&lt;div style="border: 1px dotted rgb(204, 204, 204); padding: 5px; background: rgb(239, 239, 239) none repeat scroll 0% 50%; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: Verdana;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Web.UI;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;_Default&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;Page&lt;/span&gt; 
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;//if (Request.Browser.MSDomVersion.Major == 0) // Non IE Browser? &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Cache.SetNoStore(); // No client side cashing&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Write(&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt;.NewGuid());
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
1. Load the page 
&lt;/p&gt;
&lt;p&gt;
2. Click on the button. Click event handler in server side runs and a GUID is displayed after page reloads
&lt;/p&gt;
&lt;p&gt;
3. Click Back button. As far as my machine/browser behaves, no postback happens.
&lt;/p&gt;
&lt;p&gt;
On the other hand, if using IE (7), step 3 still causes a postback.
&lt;/p&gt;
&lt;p&gt;
It does seem that it has something to do with client side caching since if you uncomment the code in Page_Load, step 3 causes a postback. The only difference with IE though is that if say you have a textbox in the same page, you place some text in the textbox and you click the back button since no client side caching is made, you loose the contents of the textbox.
&lt;/p&gt;
&lt;p&gt;
Installed FireBug to get some hint but for some reason it caused some intermittent behavior. Sometimes it works (posts back) sometimes it doesn't. Not sure though if it's FireBug causing the intermittent behavior but the "no postback behavior" predates the FireBug installation. 
&lt;/p&gt;
&lt;p&gt;
Haven't got the chance to dig deeper into this yet. Gotta get back to work :) I hope I'm just not missing something obvious here...
&lt;/p&gt;
&lt;p&gt;
Resources:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://erikmich.terapad.com/index.cfm?fa=contentNews.newsDetails&amp;amp;newsID=50003&amp;amp;from=list" rel="nofollow" mce_href="http://erikmich.terapad.com/index.cfm?fa=contentNews.newsDetails&amp;amp;newsID=50003&amp;amp;from=list" target="_blank"&gt;Prevent client caching in browsers other that Internet Explorer&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.west-wind.com/WebLog/posts/77157.aspx" rel="nofollow" mce_href="http://www.west-wind.com/WebLog/posts/77157.aspx" target="_blank"&gt;__doPostBack and the Back Button by Rick Strahl&lt;/a&gt; - some possibly relevant information but not quite since in his case, the button click and checkbox check changed event both fire in the server side, in my case the page doesn't postback at all.&lt;a href="http://www.west-wind.com/WebLog/posts/77157.aspx" rel="nofollow" mce_href="http://www.west-wind.com/WebLog/posts/77157.aspx" target="_blank"&gt;&lt;br&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6174215" width="1" height="1"&gt;</description></item><item><title>Page ViewState, Control ViewState and ControlState</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/05/08/page-viewstate-control-viewstate-and-controlstate.aspx</link><pubDate>Thu, 08 May 2008 05:49:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6168303</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6168303</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/05/08/page-viewstate-control-viewstate-and-controlstate.aspx#comments</comments><description>&lt;p&gt;
Just a quick note. I was working on some Web User Control and needed to
persist information across postbacks and thought of using ViewState.
But while I was working on it, I realized that I was using the same key
for saving another information in the parent Page's (the Page
containing the user control) ViewState.
&lt;/p&gt;
&lt;p&gt;I did a little verification and it turns out that despite having the
same key being used for saving different values to ViewState, having it
assigned inside the Web User Conrol and inside the Page results to two
different ViewState items. I verified by assigning ViewState to
the Page's and the User Control's Page_Load event handler, then since
the user control's page load fires later than the two, placed a
breakpoint after it, checked the ViewState (while inside the User
Control code) and it returned the value assigned inside it, while
calling Page.ViewState and the same key, it retrieved the value that
was previously assigned from the Page_Load of the parent Page.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;This is the behavior as far as my little test has shown but feel
free to verify in your machine and let us know how it goes especially
if the behavior is different from above. Haven't come across an explanation yet but will update this as soon as I can or maybe could stumble upon and comment. :) Nevertheless just FYI.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
This is not to be confused with Control State which is discussed more clearly from the links below:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://pluralsight.com/blogs/fritz/archive/2004/07/01/472.aspx" id="viewpost.ascx_TitleUrl" rel="nofollow" mce_href="http://pluralsight.com/blogs/fritz/archive/2004/07/01/472.aspx" target="_blank"&gt;Control state in ASP.NET 2.0 by Fritz Onion (PluralSight)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx" rel="nofollow" mce_href="http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx" target="_blank"&gt;Control State vs. View State Example on MSDN&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.beansoftware.com/ASP.NET-Tutorials/ControlState-Property.aspx" rel="nofollow" mce_href="http://www.beansoftware.com/ASP.NET-Tutorials/ControlState-Property.aspx" target="_blank"&gt;ControlState Property Demystified&amp;nbsp;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Cross post from : &lt;a href="http://ryangaraygay.com/blog/post/2008/05/Page-ViewState-Control-ViewState-and-ControlState.aspx" mce_href="http://ryangaraygay.com/blog/post/2008/05/Page-ViewState-Control-ViewState-and-ControlState.aspx"&gt;.NET Developer Notes on Page ViewState, Control ViewState and ControlState&lt;/a&gt;&lt;br&gt;

&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6168303" width="1" height="1"&gt;</description></item><item><title>Control Visibility, ViewState and Security and Performance</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/04/29/control-visibility-viewstate-and-security-and-performance.aspx</link><pubDate>Tue, 29 Apr 2008 11:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6140648</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6140648</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/04/29/control-visibility-viewstate-and-security-and-performance.aspx#comments</comments><description>&lt;p&gt;
It is not unheard of to come across a solution where use of asp:Placeholder and asp:Panel (or some other container) Visibility is employed to show/hide certain details from the user especially when when implementing "simple" Authorization/Permission features ("simple" since there are likely more complicated and/or better ways to handle it) Of course you could always implement declarative authorization features in ASP.NET but I believe it would cause the user to be redirected to the page identified as the login url and might not be applicable if you want to stay on the same page.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;
So if you simply perform checks in code you might have the following approach: Does User.Indentity.Name have permission to view this page? Yes/No? If yes, display contents of panel/placeholder, if no set their visibility to false.
&lt;/p&gt;
&lt;p&gt;
Simple and might do the trick.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;BUT&lt;/b&gt; never forget that although they are invisible, some values might be present in the viewstate (eg. values bound to gridview inside the panel/placeholder). Although viewstate might look cryptic, remember that it is just base 64 encoded string. And although you could have employ encrypted ViewState, it would still be not a good idea and you will have unnecessary overhead.
&lt;/p&gt;
&lt;p&gt;
So just a quick note to self (and possibly others) that settings PlaceHolder/Panel visibility to false doesn't stop it from saving information in viewstate. Obvious to some but not to all so if you're guilty, better fix that code before someone gets to see something they shouldn't.
&lt;/p&gt;
&lt;p&gt;
I'm also interested how best to implement this in code (not using ASP.NET built-in declarative authorization rules - ie. in web.config). HttpModule maybe? But note that I would want the resulting page to have the same look and feel (still use master page) rather than simply a text in the page (and nothing more) or worst an exception throw because user doesn't have view permission for example, nor redirected to a generic page. I'll try to explore this but someone who might have a good idea out there comes across this and shares his/her notes.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;UPDATE:&lt;/b&gt; I just realized that aside from the security consideration in this case disabling viewstate when not need would improve performance significantly (depending on how items you have in your page makes use of viewstate - eg. disabling view state when hiding a gridview is significant) so adding Performance to the title as well.&lt;/p&gt;&lt;p&gt;Also, be cautious about disabling view state. It is used by control to persist information across postbacks so if you do disable them make sure you test your page well.&lt;/p&gt;&lt;p&gt;* Cross post from &lt;a href="http://ryangaraygay.com/blog/post/2008/04/PlaceHolder-and-Panel-Visibility-and-ViewState.aspx" mce_href="http://ryangaraygay.com/blog/post/2008/04/PlaceHolder-and-Panel-Visibility-and-ViewState.aspx"&gt;.NET Developer Notes on Control Visibility, ViewState and Security and Performance&lt;br&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6140648" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Hand Editing Web.Config or not</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/04/22/hand-editing-web-config-not.aspx</link><pubDate>Tue, 22 Apr 2008 00:49:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6120100</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6120100</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/04/22/hand-editing-web-config-not.aspx#comments</comments><description>&lt;p&gt;
I've come across a number of issues in the past where the cause of the issue is that someone hand edited the web.config and resulted to a not well formed XML (missing tags, unclosed quotes et al).
&lt;/p&gt;
&lt;p&gt;
The recommended way of doing it is to minimize these issues is to use the ASP.NET Configuration Settings Dialog which is available to IIS (not sure if there is a stand alone executable for this). Here are simple steps to do it.
&lt;/p&gt;
&lt;p&gt;
1. Open IIS 
&lt;/p&gt;
&lt;p&gt;
2. Right Click on target site/virtual directory and select Properties
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&lt;img src="http://ryangaraygay.com/blog/image.axd?picture=SiteProperties.gif" mce_src="http://ryangaraygay.com/blog/image.axd?picture=SiteProperties.gif" alt=""&gt;
&lt;/p&gt;
&lt;p&gt;
3. The Properties dialog should show up. Select ASP.NET tab.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&lt;img src="http://ryangaraygay.com/blog/image.axd?picture=PropertiesASPNETTab.gif" mce_src="http://ryangaraygay.com/blog/image.axd?picture=PropertiesASPNETTab.gif" alt=""&gt;
&lt;/p&gt;
&lt;p&gt;
4. At the ASP.NET tab, you should see and click Edit Configuration. (if you're opening Properties of a website, you should also see an "Edit Global Configuration" button which corresponds to the machine wide web.config). Doing so should display the Configuration Settings Dialog
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&lt;img src="http://ryangaraygay.com/blog/image.axd?picture=ASPNETConfigurationSettingsDialog.gif" mce_src="http://ryangaraygay.com/blog/image.axd?picture=ASPNETConfigurationSettingsDialog.gif" alt=""&gt;
&lt;/p&gt;
&lt;p&gt;
5. Make your modifications without fear of unclosed quotes whatsoever. You could likely still mess up some settings but I can assure you that it would be easier to do when you're manually hand editing the file.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Also note that when adding a web.config in Visual Studio (using Add New Item) you will get a comment somewhere at the top stating:&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green128\blue0;}??\fs20 \cf1 &amp;lt;!--\cf3  \par ??    Note: As an alternative to hand editing this file you can use the \par ??    web admin tool to configure settings for your application. Use\par ??    the Website-&amp;gt;Asp.Net Configuration option in Visual Studio.\par ??    A full list of settings and comments can be found in \par ??    machine.config.comments usually located in \par ??    \\Windows\\Microsoft.Net\\Framework\\v2.x\\Config \par ??\cf1 --&amp;gt;}
--&gt;
&lt;/p&gt;
&lt;div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; Note: As an alternative to hand editing this file you can use the &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; web admin tool to configure settings for your application. Use&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; the Website-&amp;gt;Asp.Net Configuration option in Visual Studio.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; A full list of settings and comments can be found in &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; machine.config.comments usually located in &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: green;"&gt;&amp;nbsp; &amp;nbsp; \Windows\Microsoft.Net\Framework\v2.x\Config &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;--&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;br&gt;
The "Website-&amp;gt;Asp.Net Configuration option in Visual Studio" mentioned are items in the toolbar and appears if you have the website project (or its files) open/selected (see image below)
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://ryangaraygay.com/blog/image.axd?picture=WebsiteToolbarMenuItem.gif" mce_src="http://ryangaraygay.com/blog/image.axd?picture=WebsiteToolbarMenuItem.gif" alt=""&gt;
&lt;/p&gt;
&lt;p&gt;
This is also a recommended way of doing it for web site projects (not available in Web Application Projects).
&lt;/p&gt;
&lt;p&gt;
Editing web.config is likely inevitable for development but as much as possible I would recommend not hand-edit them unless you (or others in the team) really have to (especially for those with not much experience with XML/HTML - it is trivial but could minimize some headaches)&lt;/p&gt;&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt;: I have updated the post title from "Hand Editing web.config, not" to "Hand Editing web.config or not" since it seems to make a big difference. I personally hand edit most if not all web.config I work with but this is merely an alternative based on experience where there are actually people out there guilty of messing the xml for a lot of reasons. Being an alternative it may or may not be best for all situations. Also, as a starting/budding developer it is sometimes (if not all the times) best to learn from mistakes so I am in no way against hand editing of files. However like gurus out there, be careful in doing as it would probably hurt more than missing something in HTML. Furthermore for those not yet confident enough to mess up with config manually this might be for you. Although again it's best to learn from mistakes if you can afford to do so since you will surely remember it more. :)&lt;br&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6120100" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>ASP.NET Development Server cannot be accessed using non-localhost URL</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/04/19/asp-net-development-server-cannot-be-accessed-using-non-localhost-url.aspx</link><pubDate>Fri, 18 Apr 2008 19:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6110767</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6110767</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/04/19/asp-net-development-server-cannot-be-accessed-using-non-localhost-url.aspx#comments</comments><description>&lt;p&gt;An interesting point about the &lt;strong&gt;ASP.NET Development Server&lt;/strong&gt; (previously named "Cassini") 
was raised hours ago by Alvin, a coworker of mine.
&lt;/p&gt;
&lt;p&gt;
Forgive my ignorance but it seems that the said builtin server was &lt;strong&gt;constrained to be accessed only with localhost or 127.0.0.1&lt;/strong&gt; and would not work when using your IP (non loopback) nor machine name.
&lt;/p&gt;
&lt;p&gt;
For IE you get : &lt;em&gt;Internet Explorer cannot display the webpage&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
For Firefox : &lt;em&gt;Unable to connect. Firefox can't establish a connection to the server at 192.168.1.xxx:PPPP &lt;/em&gt;(port number). The page title appears as &lt;em&gt;Problem loading page&lt;/em&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Not much there but if you use Fiddler you would see that it is returning an HTTP Error 500 which refers to "Bad Gateway".
&lt;/p&gt;
&lt;p&gt;
Somehow that tells me, it's not your code but something with the server or the machine.
&lt;/p&gt;
&lt;p&gt;
Looking around, here's what I found:
&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/w566a94d.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/w566a94d.aspx" target="_blank"&gt;Troubleshooting the ASP.NET Development Server&lt;/a&gt;&lt;/p&gt;&lt;p&gt;"&lt;b&gt;Page Cannot Be Displayed" Error (502 Error)&lt;/b&gt;"&lt;br&gt;&lt;br&gt;One possible cause of a 502 error or an error indicating that the page cannot be displayed is that the browser cannot resolve a URL containing "localhost" and a port number, such as http://localhost:8080/ExampleWebSite/Default.aspx. &lt;b&gt;The ASP.NET Development Server works exclusively with localhost&lt;/b&gt;, and by default, uses a randomly selected port number for each request. &lt;br&gt;&lt;/p&gt;&lt;p&gt;Furthermore, from &lt;a href="http://msdn2.microsoft.com/en-us/library/58wxa9w5%28VS.80%29.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/58wxa9w5(VS.80).aspx" target="_blank"&gt;Web Servers in Visual Web Developer&lt;/a&gt; link you will find:
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;If you cannot or do not want to use IIS as your Web server, you can
still test your ASP.NET pages by using the ASP.NET Development Server.
The ASP.NET Development Server, which is included with Visual Web
Developer, is a Web server that runs locally on Windows operating
systems, including Windows&amp;nbsp;XP Home Edition. &lt;strong&gt;It is specifically built to
serve, or run, ASP.NET Web pages under the local host scenario
(browsing from the same computer as the Web server). In other words,
the ASP.NET Development Server will serve pages to browser requests on
the local computer. It will not serve pages to another computer.&lt;/strong&gt;
Additionally, it will not serve files that are outside of the
application scope. The ASP.NET Development Server provides an efficient
way to test pages locally before you publish the pages to a production
server running IIS. &lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Although it may seem that accessing the site from the same machine but using your IP would seem like accessing it locally, it doesn't seem to be the case. Could be that technically it would go out of your local machine first then, find which machine the IP points to so effectively it's being accessed externally already (sorry can't explain better than that). What's interesting though is that accessing the machine results in the same behavior for some reason. Maybe someone can clear it up for us. Or maybe Cassini is really accessible this way and I'm just missing something.
&lt;/p&gt;

&lt;p&gt;
One last thing, for those who wish to specify a specific port to use with ASP.NET Development Server here's a link : &lt;a href="http://msdn2.microsoft.com/en-us/library/ms178109%28VS.80%29.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms178109(VS.80).aspx" target="_blank"&gt;How to: Specify a Port for the ASP.NET Development Server&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Might seem pretty obvious for some but for those of us who haven't cared about this before then hopefully something to add to our knowledge base
(or if I'm missing something, at least something to spark your curiosity) &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6110767" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/Cassini/default.aspx">Cassini</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/ASP.NET+Development+Server/default.aspx">ASP.NET Development Server</category><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Issue with System.Transactions, SqlConnection and Timeout</title><link>http://weblogs.asp.net/ryangaraygay/archive/2008/04/14/issue-with-system-transactions-sqlconnection-and-timeout.aspx</link><pubDate>Sun, 13 Apr 2008 23:02:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6094815</guid><dc:creator>ryangaraygay</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/ryangaraygay/rsscomments.aspx?PostID=6094815</wfw:commentRss><comments>http://weblogs.asp.net/ryangaraygay/archive/2008/04/14/issue-with-system-transactions-sqlconnection-and-timeout.aspx#comments</comments><description>&lt;p&gt;
Just recently, a post was made in Microsoft Forums regarding a bug/behavior of &lt;a href="http://forums.microsoft.com/forums/showpost.aspx?postid=3026934&amp;amp;siteid=1&amp;amp;sb=0&amp;amp;d=1&amp;amp;at=7&amp;amp;ft=11&amp;amp;tf=0&amp;amp;pageid=0" mce_href="http://forums.microsoft.com/forums/showpost.aspx?postid=3026934&amp;amp;siteid=1&amp;amp;sb=0&amp;amp;d=1&amp;amp;at=7&amp;amp;ft=11&amp;amp;tf=0&amp;amp;pageid=0" target="_blank"&gt;Committable Transactions and SqlConnection timeout&lt;/a&gt;. The &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=882767&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=882767&amp;amp;SiteID=1" target="_blank"&gt;same issue is evident for TransactionScope&lt;/a&gt; which was posted in 2006. Good thing there is a fix.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;
I have used TransactionScope a number of times including in one of my previous posts on &lt;a href="http://ryangaraygay.com/blog/post/2008/04/Unit-Testing-Data-Access-with-TransactionScope.aspx" mce_href="http://ryangaraygay.com/blog/post/2008/04/Unit-Testing-Data-Access-with-TransactionScope.aspx" target="_blank"&gt;Unit Testing (integration testing if you're particular about it) DataAccess&lt;/a&gt; so will focus on it for now (but as said, same issue with Committable Transaction class).
&lt;/p&gt;

&lt;p&gt;
When you use TransactionScope and set the timeout to a certain value (not sure what is the default is not specified) and the timeout elapsed before the TX is completed, what happens is that actions made before the timeout is rolled back but after that, the connection unbinds itself from the transaction and if any action, places itself in autocommit mode (just like a regular connection) and if actions are made after the timeout (BUT still inside the TransactionScope, since these were performed in autocommit mode, they will not be rolled back).
&lt;/p&gt;

&lt;p&gt;
Trying out the code below (or the downloadable sample project at the bottom) you will notice that in the "BASIC" example (which demonstrates the issue), you try to insert 5 rows, TransactionScope timeout more or less happens after the 2nd row, then after the TransactionScope, you check the database and there are 3 rows committed (instead of NONE).&amp;nbsp;
&lt;/p&gt;

&lt;p&gt;
The good news is that MSFT found this issue too and had a fix for it a little &lt;i&gt;after the release&lt;/i&gt; (probably after the System.Transaction or release of .NET 2.0) which involves a new keyword in the connection string : &lt;b&gt;transaction binding &lt;/b&gt;defined in MSDN as :
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Controls connection association with an enlisted &lt;span class="keyword"&gt;System.Transactions&lt;/span&gt; transaction.&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Possible values are:&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&lt;span class="code"&gt;Transaction Binding=Implicit Unbind;&lt;/span&gt;&lt;/i&gt; 
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&lt;span class="code"&gt;Transaction Binding=Explicit Unbind;&lt;/span&gt;&lt;/i&gt; 
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Implicit
Unbind causes the connection to detach from the transaction when it
ends. After detaching, additional requests on the connection are
performed in autocommit mode. The &lt;span class="keyword"&gt;System.Transactions.Transaction.Current&lt;/span&gt;&lt;/i&gt;
property is not checked when executing requests while the transaction
is active. After the transaction has ended, additional requests are
performed in autocommit mode. 
&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Explicit Unbind causes the connection to remain attached to the transaction until the connection is closed or an explicit &lt;span class="keyword"&gt;SqlConnection.TransactionEnlist(null)&lt;/span&gt; is called. An &lt;span class="keyword"&gt;InvalidOperationException&lt;/span&gt; is thrown if &lt;span class="keyword"&gt;Transaction.Current&lt;/span&gt; is not the enlisted transaction or if the enlisted transaction is not active.&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;
So as you can see, the Implicit Unbind was the default behavior (which exibits the issue when the TX times out) and using explicit unbind will have the connection remain "bound" to the transaction instead of detaching itself and live it's life on it's own (and in on autocommit mode). Effectively, those actions performed after the Transaction Scope times out will also be uncommitted and we have a consistent behavior.
&lt;/p&gt;

&lt;p&gt;
Here's my code while trying to verify the issue on my own (code taken from the forums with a few additions to help illustrate better). &lt;b&gt;NOTE&lt;/b&gt;: Don't forget to modify the connection accordingly (as you see fit on your environment). Had this on VS2005, .NET 2.0 and the sample project is a console application. 
&lt;/p&gt;
&lt;div style="border: 1px dotted rgb(204, 204, 204); padding: 5px; background: rgb(239, 239, 239) none repeat scroll 0% 50%; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: Verdana;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Data.SqlClient;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Transactions;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Threading;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Demo&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; connectionString;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] argv)
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// ** Change connection strings accordingly&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"TransactionScope - BASIC"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"============================"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString = &lt;span style="color: rgb(163, 21, 21);"&gt;@"server=.\sql2005;database=testDB;integrated security=SSPI"&lt;/span&gt;;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TransactionScopeTest();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"TransactionScope - IMPLICIT UNBIND"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"============================"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString = &lt;span style="color: rgb(163, 21, 21);"&gt;@"server=.\sql2005;database=testDB;integrated security=SSPI;&lt;b&gt;transaction binding=implicit Unbind;&lt;/b&gt;"&lt;/span&gt;;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TransactionScopeTest();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"TransactionScope - EXPLICIT UNBIND"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"============================"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString = &lt;span style="color: rgb(163, 21, 21);"&gt;@"server=.\sql2005;database=testDB;integrated security=SSPI;&lt;b&gt;transaction binding=explicit Unbind;&lt;/b&gt;"&lt;/span&gt;;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TransactionScopeTest();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.ReadKey();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; TransactionScopeTest()
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ReCreateTable();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Table recreated"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;TransactionScope&lt;/span&gt; tx = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;TransactionScope&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;TransactionScopeOption&lt;/span&gt;.RequiresNew, &lt;span style="color: rgb(43, 145, 175);"&gt;TimeSpan&lt;/span&gt;.FromSeconds(2)))
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Transaction started lasting 2 seconds"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;46&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt; con = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;(connectionString)) &lt;span style="color: green;"&gt;// connection string is set in main method (see examples)&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;47&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; con.Open();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Server is {0}"&lt;/span&gt;, con.ServerVersion);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Clr is {0}"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;Environment&lt;/span&gt;.Version);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;51&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;52&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;for&lt;/span&gt; (&lt;span style="color: blue;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 5; i++)
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt; cmd = con.CreateCommand())
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;56&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.CommandText = &lt;span style="color: rgb(163, 21, 21);"&gt;"insert into TXTEST values ( "&lt;/span&gt; + i + &lt;span style="color: rgb(163, 21, 21);"&gt;" )"&lt;/span&gt;;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;57&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.ExecuteNonQuery();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;58&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Row inserted"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;59&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;60&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;61&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Thread&lt;/span&gt;.Sleep(&lt;span style="color: rgb(43, 145, 175);"&gt;TimeSpan&lt;/span&gt;.FromSeconds(1));
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;62&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;63&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;64&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Committing... now we get the timeout (sort of)"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;65&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;66&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tx.Complete();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;67&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;68&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;69&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;70&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;71&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Exception&lt;/span&gt; e)
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;72&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;73&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(e.Message);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;74&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;75&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;76&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Table contains {0} rows!!!"&lt;/span&gt;, CountTable());
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;77&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DropTable();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;78&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;79&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;80&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Exception&lt;/span&gt; e)
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;81&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;82&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Unexpected error:"&lt;/span&gt;);
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;83&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(e.ToString());
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;85&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;86&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;87&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ReCreateTable()
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;88&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;89&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;90&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;91&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DropTable();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;92&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;93&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;94&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Exception&lt;/span&gt;) { }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;95&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt; con = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;(connectionString)) &lt;span style="color: green;"&gt;// connection string is set in main method (see examples)&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; con.Open();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;99&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"create table TXTEST ( F1 int )"&lt;/span&gt;, con))
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;100&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.ExecuteNonQuery();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;101&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;102&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;103&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;104&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; CountTable()
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;105&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;106&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt; con = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;(connectionString)) &lt;span style="color: green;"&gt;// connection string is set in main method (see examples)&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;107&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;108&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; con.Open();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;109&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"select count(*) from TXTEST"&lt;/span&gt;, con))
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;110&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)cmd.ExecuteScalar();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;111&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;112&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;113&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;114&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; DropTable()
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;115&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;116&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt; con = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;(connectionString)) &lt;span style="color: green;"&gt;// connection string is set in main method (see examples)&lt;/span&gt;
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;117&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;118&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; con.Open();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;119&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"drop table TXTEST"&lt;/span&gt;, con))
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;120&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.ExecuteNonQuery();
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;121&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;122&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;

&lt;p style="margin: 0px;"&gt;
&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;123&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href="http://ryangaraygay.com/blog/file.axd?file=TransactionTimeoutIssue.zip" rel="enclosure" mce_href="http://ryangaraygay.com/blog/file.axd?file=TransactionTimeoutIssue.zip"&gt;Download Demo - TransactionTimeoutIssue.zip (5.05 kb)&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The sample project also contains another class for illustrating the issue with Committable Transaction. Just exclude the TransactionScope class and uncomment the Main method in CommittableTransactionDemo.cs.&amp;nbsp;
&lt;/p&gt;

&lt;p&gt;
Please feel free to drop me message if I'm missing something or if there's any issues with the download. :D 
&lt;/p&gt;

&lt;p&gt;
More Information:
&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/ms172152.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms172152.aspx" target="_blank"&gt;MSDN - Implementing an Implicit Transaction with TransactionScope&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx" target="_blank"&gt;MSDN - ConnectionString&lt;/a&gt;
&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6094815" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ryangaraygay/archive/tags/.NET/default.aspx">.NET</category></item></channel></rss>