2007-12-27

Using Transactions.TransactionScope

Trying to do with: running Using scope As Transactions.TransactionScope = New Transactions.TransactionScope() in vs 2005 pro by vb.net
Searched by: TransactionScope imports
Source from: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic59025.aspx


"Namespace or type specified in the imports 'System.Transactions' doesn't contain any public member or cannot be found. Make sure then namespace... etc."

When I visit the properties of the project and check the available references I can't find it there either. Do I have to do something extra before using that Namespace?


If you are using Visual Studio 2005 Standard Editon & above do the following
Right click on the project
Add Reference
you'll definitely see reference System.Transaction under .NET references in
the references tab.

MSDTC on server is unavailable.

Trying to do with: running Using scope As Transactions.TransactionScope = New Transactions.TransactionScope() in vs 2005 pro by vb.net
Searched by: MSDTC on server is unavailable
Source from: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=54705




[*]

On the server where the trigger resides, you need to turn the MSDTC service on. You can this by clicking START > SETTINGS > CONTROL PANEL > ADMINISTRATIVE TOOLS > SERVICES. Find the service called 'Distributed Transaction Coordinator' and RIGHT CLICK (on it and select) > Start.

Test the trigger and see if it works. If it still does not work, wrap you trigger in the following transaction code (found below in bold):


SET XACT_ABORT ON
BEGIN DISTRIBUTED TRANSACTION


-- Put all queries in here (SELECT, INSERT, UPDATE, and DELETE)
select * from [SERVER2].[DBASE].[OWNER].[TABLENAME]
update [SERVER2].[DBASE].[OWNER].[TABLENAME]
set [column] = value
where [condition(s)]

COMMIT TRANSACTION
SET XACT_ABORT OFF



This solution solved our problems, I hope they solve yours.
We ran into the following errors, and the above fixed them:
1. MSDTC on server is unavailable. [fixed this error by started the service above [*] ]
2. Server: Msg 7395, Level 16, State 2, Procedure name, Line 26
Unable to start a nested transaction for OLE DB provider 'SQLOLEDB'. A nested transaction was required because the XACT_ABORT option was set to OFF.
[OLE/DB provider returned message: Cannot start more transactions on this session.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionLocal::StartTransaction returned 0x8004d013: ISOLEVEL=4096].

Google Referrals