Re: Connection Pooling

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



In the object oriented world objects work with Database.
So it's common for 2 different objects to update it's own pieces of databases.
for example:
Let say you have a rule if person withdraws money from his checking account and do not have balance available the money is taken from his saving account.
So here is the pseducode.

clsAccount objChecking, objSaving;
.....
if( objChecking.AvailableBalance < NeededAmount )
{
objSavings.Take(NeededAmount);
objChecking.Put(NeededAmount);
}
objChecking.GiveCash(NeededAmount);

If the 'Put' method fails we need to reverse 'Take' action...
in a simple world (not object oriented) you would issue DBConnection.AbortTransaction and it will be like the method 'Take' never happened.
But in object oriented world, each object objSavings and objChecking had created it's own DBConnection and had performed the UPDATE statement on it.

So the question is how do you Abort transaction on 2 separate DB connections.
So now (when Enlist = true) each connection (opened on current thread) is enlisted into single 'Global' transaction and if that transaction is aborted all actions perfomed by this connection will rollback.
-----------------------------
I hope i am clear.

So if you set Enlist = false then you will save some runtime. But then you will not be able to do rollback of the 'global' transaction. By default all Global transaction will commit so if you are not doing anything special to roll them back you can safely set it to Enlist = false. You can keep it as true but then you just wasting some runtime.

FYI: The service that manages Global transactions is called 'Microsoft Distributed Transaction Coordinator' you can google it if you want to find more info. It's comes with Windows.


George.


"Marc" <noreply@xxxxxxxxx> wrote in message news:uVhR6rb8IHA.3736@xxxxxxxxxxxxxxxxxxxxxxx
I am reading some book over dotnet. I do not understand this sentence considering connection pooling:

Enlist When this value is true, the connection is automatically enlisted into the
creation threads current transaction context. The default is true.

What is enlisted? It's put on some list? And what is the current transaction context? And why does the creation thread has such a context?

Sorry I do not understand much about this sentence.


.



Relevant Pages

  • Re: SQLCE 3.0 losing data after transaction
    ... You can also control the flush scheduling time using Connection String ... only SqlCeResultSet to get data from the database. ... CommandType.Text) As SqlCeCommand ... If Transaction IsNot Nothing Then ...
    (microsoft.public.sqlserver.ce)
  • Re: Problem with SQLServerCE
    ... deployed and overwriting the new and updated database file on the device. ... SqlCeTransaction transaction = null; ... connection = GetConnection; ... SqlCeCommand command = new SqlCeCommand("SELECT id from ...
    (microsoft.public.sqlserver.ce)
  • Re: Connection types and speeds
    ... The memory used by holding the connection open is not ... All recordset inserts seen to consequently have 0ms execution time, ... actually written to the database while the code has regained control ... RecordsetClone of a form) when a transaction was rolled back, ...
    (microsoft.public.access.queries)
  • Re: Problem with SQLServerCE
    ... all the operations done against the database work fine for some ... SqlCeTransaction transaction = null; ... connection = GetConnection; ... SqlCeCommand command = new SqlCeCommand("SELECT id from ...
    (microsoft.public.sqlserver.ce)
  • Re: psycopg, transactions and multiple cursors
    ... > first time a change is made to the database. ... My intention is actually to keep them in the same transaction. ... >> cursor fetches one record from the database at a time). ... > generated from the same connection, ...
    (comp.lang.python)