none
Ho to use Transactions in Linq to SQL RRS feed

  • General discussion

  • <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->

    Hi this is the code I used to make a transaction between  TableA and TableB .

    I found the Data is added properlly in TableA but TableB is not getting updated.

    No exceptions.I made enough break points and checked the code but still cant

    understand the problem.....

     

    try

    {

    using (TransactionScope scope = new TransactionScope())

    {

      tableA = new TableA();

      tableA.Col1=10;

      tableA.Col2=20;

      if (tableAService.AddSingleItem<TableA>(tableA))

      {

      tableB= tableBService.GetDetails(Convert.ToInt32(Request["col1"]));

      tableB.Col1=110;

      tableB.Col2=210;

    if (tableBService.Modify<TableB>(tableB))

      {

      scope.Complete();

      }

    }

    }

    catch (Exception ex)

    {

      Console.WriteLine(ex.Message.ToString());

    }

    • Moved by Bob Beauchemin Tuesday, September 15, 2009 11:21 PM Moved to a more appropriate group (From:.NET Framework inside SQL Server)
    • Changed type Zhipeng Lee Monday, September 21, 2009 3:59 AM
    Tuesday, September 15, 2009 10:52 AM

All replies

  • Hi Mr.Nobody,

     

    To solve the problem, you need to provide more details about your case. For example, how do you persist your updates to the database? Your 'TableB is not getting updated' just means 'the object is not updated', instead of checking the tables in the database?

    Looking forward to your explanation.


    Best regards, Charlie Lee Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, September 17, 2009 9:22 AM