The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Transaction not working in VB.Net

Last post 04-04-2007, 7:51 AM by dburgett. 1 replies.
Sort Posts: Previous Next
  •  04-04-2007, 7:34 AM 1596

    Transaction not working in VB.Net

    I've got to be missing something simple because I know this example works in C#. (I recently started a new job where they use VB.Net so I'm porting some code...)

    I'm writing a simple unit test to demonstrate how esTransactions are used. This is using the Northwind database in SqlServer 2005.  I'm creating a transaction and then changing the name of the first Category and the first Product. Then I dispose of the transaction object without calling the .Complete() method. This should undo the changes I made to the Category and the Product, but it's not.

    I have tried this using two different methods as show below. I have the latest full (not trial) version of ES (1.5.3).

    Code Set #1:
    Dim _Category As Categories = New Categories()
    _Category.LoadByPrimaryKey(1)
    _Category.CategoryName = "BAD NAME"
    
    Dim _Product As Products = New Products()
    _Product.LoadByPrimaryKey(1)
    _Product.ProductName = "BAD NAME"
    
    Dim _Transaction As esTransactionScope = New esTransactionScope()
    
    Try
       With _Transaction
          _Category.Save()
          _Product.Save()
       End With
    Finally
       CType(_Transaction, IDisposable).Dispose()
    End Try

     

    Code Set #2:
    Dim _Category As Categories = New Categories()
    _Category.LoadByPrimaryKey(1)
    _Category.CategoryName = "BAD NAME"
    
    Dim _Product As Products = New Products()
    _Product.LoadByPrimaryKey(1)
    _Product.ProductName = "BAD NAME"
    
    Dim _Transaction As esTransactionScope = New esTransactionScope()
    Try
       _Category.Save()
       _Product.Save()
    Finally
       CType(_Transaction, IDisposable).Dispose()
    End Try
    
    I also tried moving the Categories/Products declarations to after the Transaction declaration to no avail. 
    I also tried throwing an Exception at the end of the try but that didn't help either.
    Any help would be greatly appreciated.
    Thank you, David Burgett
    Filed under: ,
  •  04-04-2007, 7:51 AM 1597 in reply to 1596

    Re: Transaction not working in VB.Net

    Let me answer my own question...

    I was using providerClass="DataProviderEnterprise" in my configuration file. Apparently this does not work with SQL Server 2005.

    When I changed this to providerClass="DataProvider", everything worked as expected.

     

    Thank you, David Burgett

    Filed under: ,
View as RSS news feed in XML