Multiple transactions on the same connection?

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

Kirti

Hi,
Wanted to know if I can have multiple transactions over the same
connection.

I am planning to have only one connection object in my application.

For multiple users I want to begin different transctions over the same
connection. I would be storing the transaction objects by userid in a
hashtable. All the methods would then take in the userid and also know
the right transaction object to be associated to the command object.

Would this work.. ??

I do not think the transactions would be nested..as do not know what
each user might do..

Thanks in advance.
 
Hi everybody,
I'm a recently user.

I understood the answer to the original question (One connection, one
transaction). Now I have the following trouble:

I have an application and I need to capture data, but I have to
refresh two diferents DB.

Just to be a developer with good in mind, I have to use a transaction,
but how can I use a transaction (or various transactions) to be sure
that the information is saved in both DB ???????? (the main thing is
that if there are one error delete every information inserted in that
transaction in both DB -in other words rollback for all the DB-)


Thanks everybody and I hope to get an answer.
 
Distributed Transactions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/disttranvbnet.asp
will do the trick. This entails using COM + (Matt MacDonald's Enterprise
Applications book is a great resource). This is greatly simplified in
ADO.NET 2.0 and http://weblogs.asp.net/angelsb/ Angel has some great
examples and I've got a quick one here
http://forums.devbuzz.com/A_quick_look_at_ADO%NET_2%0's_TransactionScope_Object/m_31498/tm.htm

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
You could roll 2 separate transactions. Don't commit them until all the
operations on both DB's succeed. If one fails, roll both back.

Of course, this isn't 100% reliable. You could commit the 1st transaction,
but not be able to commit the 2nd for some reason.

A more robust solution would be to use COM+, so look at the
System.EnterpriseServices namespace, particularly the ServicedComponent
class.
 
dbarriguete said:
Hi everybody,
I'm a recently user.

I understood the answer to the original question (One connection, one
transaction). Now I have the following trouble:

I have an application and I need to capture data, but I have to
refresh two diferents DB.

Just to be a developer with good in mind, I have to use a transaction,
but how can I use a transaction (or various transactions) to be sure
that the information is saved in both DB ???????? (the main thing is
that if there are one error delete every information inserted in that
transaction in both DB -in other words rollback for all the DB-)

Look into enterprise services and ServicedComponent. You need a COM+
transaction to coordinate the database activity to the 2 different database
as 1 single transaction. Only then you can rollback all actions on both
databases.

Your database has to support COM+ transactions. Not all databases do that.

FB
 
OK, Thanks everybody for your answers.

I have to use two differents transaction because I have a Windows 2000
Server, and System.EnterpriseServices namespace have classes that just
work in Windows 2003 or higher :-S

It's not the better solution but we don't have the resources to do it
correctly
 
Back
Top