DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 06 Jul 2007 15:44:33 -0400,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    lucius am
          2    Milosz Skalecki [MCAD]
          3    (WenYuan Wang [MSFT])
          4    (WenYuan Wang [MSFT])


Transaction Scope and DTC Needs?   
I am trying to use a lightweight transaction to encapsulate multiple
sqlcommands on a connection (they update different databases in the
same named sqlserver instance) so if one update fails they will all
roll back. My development system is XP Pro and when I try to test the
below code I get an error about MSDTC being disabled. 
using ( TransactionScope scope = new TransactionScope() )
{
	using ( SqlConnection con = new SqlConnection(connstring) )
	{
		con.Open();
		cmd1.ExecuteNonQuery();
		cmd2.ExecuteNonQuery();
	}
	scope.Complete();
}

Can someone point out how to not use MSDTC when doing (lightweight)
transactions? The code will ultimately live in a class in an ASP.NET
2.0 web site.

Thanks.
Date:Fri, 06 Jul 2007 15:44:33 -0400   Author:  

RE: Transaction Scope and DTC Needs?   
Howdy,

http://msdn2.microsoft.com/en-us/library/ms172152.aspx

In addition, make sure MSDTC is properly configured (meaning it's stared, 
and traffic is open between ASP.NET machine and SQL server (Control 
Panel-Administrative Tools-Component Services-Expand to My Computer-Right 
Click-Properties-MSDTC.

Hope this helps
-- 
Milosz


"lucius" wrote:


> 
> 
> 
> I am trying to use a lightweight transaction to encapsulate multiple
> sqlcommands on a connection (they update different databases in the
> same named sqlserver instance) so if one update fails they will all
> roll back. My development system is XP Pro and when I try to test the
> below code I get an error about MSDTC being disabled. 
> using ( TransactionScope scope = new TransactionScope() )
> {
> 	using ( SqlConnection con = new SqlConnection(connstring) )
> 	{
> 		con.Open();
> 		cmd1.ExecuteNonQuery();
> 		cmd2.ExecuteNonQuery();
> 	}
> 	scope.Complete();
> }
> 
> Can someone point out how to not use MSDTC when doing (lightweight)
> transactions? The code will ultimately live in a class in an ASP.NET
> 2.0 web site.
> 
> Thanks.
> 
Date:Sun, 8 Jul 2007 04:14:00 -0700   Author:  

RE: Transaction Scope and DTC Needs?   
Hello Lucius,
Thanks for Howdy's info.

According to your initial post, it seems you want to use Lightweight 
transaction to enlist only one connection, however, meet an issue that 
transaction scope told you it need enable MSDTC. Please correct me if I 
misunderstand anything here. Thanks.

For Sql2k5, the transaction is managed by LTM until the second 
SqlConnection connected to a different database comes into picture. But, In 
Sql 2k, the transaction will be managed by MSDTC even if you have ONE 
single database involved. 

In my opinion, if your asp.net application connect single database and want 
to use Lightweight transaction, I would like to recommend SqlTransaction.
SqlTransaction could only work on single databases and is Lightweight 
transaction. The drawback is that you should explicitly enroll in the 
transaction.

For the difference between SQLTranscation and TranscationScop, please refer 
to
http://dotnetslackers.com/SQL/re-3498_SqlTransaction_vs_System_Transactions.
aspx
[SqlTransaction vs. System.Transactions ]

For an example about how to use SQLTranscation, please refer to
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqltransactio
n.commit.aspx
[SqlTransaction.Commit Method]

Hope this helps.
Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 09 Jul 2007 08:25:03 GMT   Author:  

RE: Transaction Scope and DTC Needs?   
Hello Lucius,

This is Wen Yuan again. Have you tried with SQLTranscation?
I just want to check if there is anything we can help with.
Please feel free to update here if you meet any futher issue.
We are glad to work with you.:)

Have a great day,
Sincerely,
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 12 Jul 2007 03:18:28 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us