Re: Simple TransactionScope problem, please help

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



Now I found some other things. If I change the database to a local database,
like this:
SqlConnection conn = new SqlConnection(@"integrated security=SSPI;data
source=(local);initial catalog=Northwind");

It works.
So the problem is why this TransactionScope does not work on remote database
server.

Thanks.

"Sahil Malik [MVP C#]" wrote:

There is a 1 minute default transaction timeout on TransactionScope.

SM



"BF" <BF@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@xxxxxxxxxxxxxxxx
Actually, I don't think this is a timeout issue. I only open a connection
to
a database on local network. If you don't use TransactionScope, I can open
this connection in no time.

But if I use TransactionScope, it wait and wait until time out. I think
this
problem is when I use TransactionScope, I cannot open database connection
at
all.

Thanks a lot.


"Sahil Malik [MVP C#]" wrote:

TransactionScope based transactions have a default timeout of 1 minute -
after which if you snooze for that long, it would have autorolled back.
This
is done to conserve resources from bad programmers.

You can change the timeout using one of the constructors. :)


--
- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------

"BF" <BF@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA6ACA66-D091-487D-862A-A28E08F5D021@xxxxxxxxxxxxxxxx
This problem is so simple I am surprised it's happening.

When I run the following code:

using (TransactionScope ts = new TransactionScope())
{
SqlConnection conn = new SqlConnection(@"integrated
security=SSPI;data source=WSDEV\GODS;initial catalog=MOSES");
conn.Open();
}

It waits at conn.Open(); for over 1 minute and return error message
"The
transaction has already been implicitly or explicitly committed or
aborted.".

If I comment out TransactionScope line, it works without any problems.
So
the connection string is correct.

Can anybody point out what's happening here?

Thanks a lot.







.



Relevant Pages

  • Re: How to stop TransactionScope from starting distributed transac
    ... Even if it is the same database, opening and closing multiple times will ... actually create more than one opened connection. ... I will open and close SqlConnection many ... Will this cause TransactionScope promote MSDTC? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Simple TransactionScope problem, please help
    ... It's the firewall on my Windows/XP. ... There is no timeout property for TransactionScope. ... The database is on local area network. ... Authentication database connection? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Simple unit test for TransactionScope not working!
    ... A database connection object will only ... auto-enlist in a transactionscope if the transactionscope exists at the time ... using (IDbConnection conn2 = RDBMSLayer.DBConnect()) ...
    (microsoft.public.dotnet.framework.adonet)
  • Is it SQL 2008 or VB 2008 problem? I dont know
    ... The application imports CSV files in the database. ... connecting to the database that I made it with SQL Server 2005. ... The application uses the TransactionScope class this way with no problem: ... also switched my database from 2005 to SQL Server 2008 Express Edition. ...
    (microsoft.public.dotnet.languages.vb)
  • Is it a SQL 2008 or VB 2008 problem? I dont know
    ... The application imports CSV files in the database. ... connecting to the database that I made it with SQL Server 2005. ... The application uses the TransactionScope class this way with no problem: ... also switched my database from 2005 to SQL Server 2008 Express Edition. ...
    (microsoft.public.sqlserver.programming)