Note that there are some explanatory texts on larger screens.

plurals
  1. POTransactionScope works in some places and not in others
    primarykey
    data
    text
    <p>Using ASP.NET 3.5, Linq to SQL, SQL Server 2005 on Windows Server 2003. Running VS 2008 on XP SP3 locally.</p> <p>We need to be able to wrap inserts, updates, and deletes in a transaction. When we first tried this by wrapping code blocks with <code>using(var trans = new TransactionScope()) { ...; trans.Complete(); }</code>, we got an appropriate exception telling us we needed to enable network access for remote transactions. <a href="http://support.microsoft.com/kb/817064" rel="nofollow noreferrer">We did so</a> and things began to work the way we expected. </p> <p>Fast forward to today. There is a little-used part of our app that also received a TransactionScope treatment. Though transactions work properly in all other parts of our codebase, we discovered today that this seldom used piece is throwing the same "Network Access" exception as before:</p> <p><a href="http://img101.imageshack.us/img101/5480/msdtcnetworkaccesserror.jpg" rel="nofollow noreferrer">Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool. http://img101.imageshack.us/img101/5480/msdtcnetworkaccesserror.jpg</a> </p> <p>Here's the code that causes the exception:</p> <pre><code> using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, TimeSpan.MaxValue)) { using (var dc = new ChargeXferDataContext()) { //create 'Line' object and set initial values Line line = new Line(); line.Unit_Num = UnitId; line.SubmittedBy = Viewer.Alias(); line.LineSubmittedOn = DateTime.Now; //get codes to move from checked rows //iterate rows in current gridview foreach (GridViewRow row in gv.Rows) { //if checked, insert move order HtmlInputCheckBox cb = (HtmlInputCheckBox)row.FindControl("RowLevelCheckBox"); if (cb.Checked) { //1st: get required values int id = Convert.ToInt32(((TextBox)row.FindControl("fldCodeId")).Text); int newId = Convert.ToInt32(((DropDownList)row.FindControl("ddlNewId")).SelectedValue); char newPOA = Convert.ToChar(((DropDownList)row.FindControl("ddlPOA")).SelectedValue); //2nd: get current diag code from old patient //######## Exception happens here... DiagCode code = dc.DiagCodes.SingleOrDefault(c =&gt; c.Id == id); //######## //3rd: add code to emenline object addCode(line, code, newId, newPOA); } } dc.SubmitChanges(); trans.Complete(); } } </code></pre> <p>If you've got any suggestions, they would be appreciated. Let me know if I can explain something more. Thanks in advance!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload