|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple TransactionScope problem, please helpWhen 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. 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. :) -- Show quote- Sahil Malik [MVP] ADO.NET 2.0 book - http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx ---------------------------------------------------------------------------- "BF" <B*@discussions.microsoft.com> wrote in message news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... > 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. > 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. Show quote "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" <B*@discussions.microsoft.com> wrote in message > news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... > > 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. > > > > > There is a 1 minute default transaction timeout on TransactionScope.
SM Show quote "BF" <B*@discussions.microsoft.com> wrote in message news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@microsoft.com... > 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" <B*@discussions.microsoft.com> wrote in message >> news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... >> > 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. >> > >> >> >> I just checked MSDN for all members of TransactionScope at
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref12/html/T_System_Transactions_TransactionScope_Members.htm
There is no timeout property for TransactionScope. And the error I get is "The transaction has already been implicitly or explicitly committed or aborted". I get this error after 1 minute 20 seconds of waiting. So I believe there are some other settings or limitations causing this error. The code is so simple. The database is on local area network. There are must be some easy reason for this. Does TransactionSope support Windows Authentication database connection? Thanks a lot. Show quote "Sahil Malik [MVP C#]" wrote: > There is a 1 minute default transaction timeout on TransactionScope. > > SM > > > > "BF" <B*@discussions.microsoft.com> wrote in message > news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@microsoft.com... > > 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" <B*@discussions.microsoft.com> wrote in message > >> news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... > >> > 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. > >> > > >> > >> > >> > > > Did you see the CONSTRUCTOR for TransactionScope?
System.Transactions.TransactionScope tsc = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, new TimeSpan(8943893993)) ; - Sahil Malik [MVP] ADO.NET 2.0 book - http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx ---------------------------------------------------------------------------- Show quote "BF" <B*@discussions.microsoft.com> wrote in message news:7DD5FE9F-ABF3-456D-96E6-19F77ACBD080@microsoft.com... >I just checked MSDN for all members of TransactionScope at > ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref12/html/T_System_Transactions_TransactionScope_Members.htm > > There is no timeout property for TransactionScope. > > And the error I get is "The transaction has already been implicitly or > explicitly committed or aborted". > I get this error after 1 minute 20 seconds of waiting. > > So I believe there are some other settings or limitations causing this > error. The code is so simple. The database is on local area network. There > are must be some easy reason for this. Does TransactionSope support > Windows > Authentication database connection? > > Thanks a lot. > > > "Sahil Malik [MVP C#]" wrote: > >> There is a 1 minute default transaction timeout on TransactionScope. >> >> SM >> >> >> >> "BF" <B*@discussions.microsoft.com> wrote in message >> news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@microsoft.com... >> > 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" <B*@discussions.microsoft.com> wrote in message >> >> news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... >> >> > 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. >> >> > >> >> >> >> >> >> >> >> >> Yes, there is a scope time out in the contructor. But I found the real reason
behind the problem. It's the firewall on my Windows/XP. If I turn off the firewall, I can run this code without any problems. I will start a new thread for this question. Thanks a lot. Show quote "Sahil Malik [MVP C#]" wrote: > Did you see the CONSTRUCTOR for TransactionScope? > > System.Transactions.TransactionScope tsc = new > System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, > new TimeSpan(8943893993)) ; > - Sahil Malik [MVP] > ADO.NET 2.0 book - > http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx > ---------------------------------------------------------------------------- > > > > "BF" <B*@discussions.microsoft.com> wrote in message > news:7DD5FE9F-ABF3-456D-96E6-19F77ACBD080@microsoft.com... > >I just checked MSDN for all members of TransactionScope at > > ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref12/html/T_System_Transactions_TransactionScope_Members.htm > > > > There is no timeout property for TransactionScope. > > > > And the error I get is "The transaction has already been implicitly or > > explicitly committed or aborted". > > I get this error after 1 minute 20 seconds of waiting. > > > > So I believe there are some other settings or limitations causing this > > error. The code is so simple. The database is on local area network. There > > are must be some easy reason for this. Does TransactionSope support > > Windows > > Authentication database connection? > > > > Thanks a lot. > > > > > > "Sahil Malik [MVP C#]" wrote: > > > >> There is a 1 minute default transaction timeout on TransactionScope. > >> > >> SM > >> > >> > >> > >> "BF" <B*@discussions.microsoft.com> wrote in message > >> news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@microsoft.com... > >> > 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" <B*@discussions.microsoft.com> wrote in message > >> >> news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... > >> >> > 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. > >> >> > > >> >> > >> >> > >> >> > >> > >> > >> > > > 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. Show quote "Sahil Malik [MVP C#]" wrote: > There is a 1 minute default transaction timeout on TransactionScope. > > SM > > > > "BF" <B*@discussions.microsoft.com> wrote in message > news:C96D5EF2-4DDC-469F-B3E8-8FC189788D04@microsoft.com... > > 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" <B*@discussions.microsoft.com> wrote in message > >> news:CA6ACA66-D091-487D-862A-A28E08F5D021@microsoft.com... > >> > 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. > >> > > >> > >> > >> > > > |
|||||||||||||||||||||||