Manual Transaction Handling with Remoting & Multiple Users

  • Thread starter Thread starter Kirti
  • Start date Start date
K

Kirti

I am using .Net remoting for our server side application which
connects to the database.
I want to put transaction handling in there and do not want to use
Com+ to keep things simple.


I have a scenario where
My client is making calls like
Function TEST()
{
Insert A - this is going to the server
Insert B - this is again going to the server
Update C - This is also a call to the server.
}

Function Test2()
{
Insert Q - server side
Update P - server side call
Insert R - Server side
}

I can always create a connection object and then create a Transaction
object for handling the Transactions.

Consider I have a class for the database..

sqldb.cs
{
ConnectionCurrent is the connection Object
TransactionCurrent is the transaction object

I write new methods like
beginConn()
{
//this will check for the connection and if it is
not open , open it
// It will also create the Transactioncurrent

TransactionCurrent =
ConnectionCurrent.beginTransaction()
}
CommitTrans()
{
TransactionCurrent.Commit()
}
RollBackTrans()
{
TransactionCurrent.RollBack()
}


I already have methods like
Insert A()
Insert Q () etc..

}

My functions would then be modified such that

Function TEST()
{
try
{
beginConn()
Insert A - this is going to the server
Insert B - this is again going to the server
Update C - This is also a call to the server.
CommitTrans()
}
catch
{
RollBackTrans()
}
finally()
{
CloseConnection()

}
}

Function Test2()
{
try
{
beginConn()
Insert Q - server side
Update P - server side call
Insert R - Server side
CommitTrans()
}
catch
{
RollBackTrans()
}
finally()
{

CloseConnection()
}
}

But what would happen if I have 2 different users.
One user is calling Function Test() ,(this would create the
transactioncurrent) and the 2nd user is calling Function Test2() at
the same time.

Would there be a problem. Or would it be taken care of by the
Connection Pooling.

Or would there be a problem as it is the same transaction object
(transactioncurrent) that is being used?

Thanks in advance.
 
Hi Kirti,

If I understand your question correctly then the answer would be to create a
new connection for both functions before accessing databse.
Then the pooling will create two physical connections if necessary.
 
Back
Top