Transactions through Remoting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan H

    #1

    Transactions through Remoting

    Hi,

    My data access layer for my VB.NET 1.1 application resides on a different
    server and is accessed via Remoting.

    Is there a way to configure my data access layer so that I can use
    Transactions? For example, I would like to do the following from the client:

    Try
    DataAccessLayer Class.RunSQL("U PDATE MyTable SET Column3 = "aa", ConnObj,
    TransactionObj)
    SendEmail()
    TransactionObj. Commit
    Catch
    ' Update or sending of email failed
    TransactionObj. Rollback
    End Try

    Any help on how to use Transactions while the data access layer is accessed
    via Remoting would be appreciated.
    I am also open to rewriting my current code (i.e. change data access
    location) if there is an alternative solution.

    Thanks.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Transactions through Remoting

    Ryan,

    This is a really bad design for your data layer for a number of reasons.

    First, you are passing sql statements to your data layer. This is
    unadvisable, as you should use stored procs instead. Also, if you have to
    pass SQL statements, you should at least make sure that you parameterize
    them so that you protect yourself against injection attacks.

    But that's not the real problem here. Here, you are passing your
    connection and transaction object to your data layer. The problem with this
    is that those objects both derive from MarshalByRefObj ect. This means that
    a proxy is passed to your data layer and any calls to methods/properties on
    the connection/transaction are being made back to your machine.

    What you really should be doing is handling this in process. You aren't
    gaining anything by sending it to another machine, since you are opening the
    connection on yours.

    Either that, or have the data layer construct the connection.

    However, that doesn't solve the issue you have with managing the
    transaction. In reality, you need to make the operation that you are
    performing transactional. There are a few ways of doing this.

    The first would be to use .NET 2.0 and use the TransactionScop e class to
    encapsulate the transaction scope. The second would be to create a COM+
    component through the classes in the System.Enterpri seServices namespace.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Ryan H" <rherrera@smci. comwrote in message
    news:e%23vzKvmt GHA.4748@TK2MSF TNGP03.phx.gbl. ..
    Hi,
    >
    My data access layer for my VB.NET 1.1 application resides on a different
    server and is accessed via Remoting.
    >
    Is there a way to configure my data access layer so that I can use
    Transactions? For example, I would like to do the following from the
    client:
    >
    Try
    DataAccessLayer Class.RunSQL("U PDATE MyTable SET Column3 = "aa", ConnObj,
    TransactionObj)
    SendEmail()
    TransactionObj. Commit
    Catch
    ' Update or sending of email failed
    TransactionObj. Rollback
    End Try
    >
    Any help on how to use Transactions while the data access layer is
    accessed via Remoting would be appreciated.
    I am also open to rewriting my current code (i.e. change data access
    location) if there is an alternative solution.
    >
    Thanks.
    >

    Comment

    • Michael Nemtsev

      #3
      Re: Transactions through Remoting

      Hello Ryan,

      RHMy data access layer for my VB.NET 1.1 application resides on a
      RHdifferent server and is accessed via Remoting.
      RH>
      RHIs there a way to configure my data access layer so that I can use
      RHTransactions? For example, I would like to do the following from the
      RHclient:

      You need to use Transaction attribute, it available from EnterpriseServi ces
      namespace

      RHAny help on how to use Transactions while the data access layer is
      RHaccessed
      RHvia Remoting would be appreciated.

      AFAIK, there could be a problem if u use COM+, because context that take
      a part in DTC can be send across network only via DCOM, not remoting

      ---
      WBR,
      Michael Nemtsev :: blog: http://spaces.msn.com/laflour

      "At times one remains faithful to a cause only because its opponents do not
      cease to be insipid." (c) Friedrich Nietzsche


      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Transactions through Remoting

        Michael,

        Using the Transaction attribute won't work outside of COM+, so if he is
        going to go this route, he has to go through Enterprise Services.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Michael Nemtsev" <nemtsev@msn.co mwrote in message
        news:9cc1c863a4 53a8c884a8ee9f3 b7f@msnews.micr osoft.com...
        Hello Ryan,
        >
        RHMy data access layer for my VB.NET 1.1 application resides on a
        RHdifferent server and is accessed via Remoting.
        RHRHIs there a way to configure my data access layer so that I can use
        RHTransactions? For example, I would like to do the following from the
        RHclient:
        >
        You need to use Transaction attribute, it available from
        EnterpriseServi ces namespace
        >
        RHAny help on how to use Transactions while the data access layer is
        RHaccessed
        RHvia Remoting would be appreciated.
        >
        AFAIK, there could be a problem if u use COM+, because context that take a
        part in DTC can be send across network only via DCOM, not remoting
        >
        ---
        WBR,
        Michael Nemtsev :: blog: http://spaces.msn.com/laflour
        >
        "At times one remains faithful to a cause only because its opponents do
        not cease to be insipid." (c) Friedrich Nietzsche
        >
        >

        Comment

        Working...