473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Transaction IsolationLevel problem

Hi all,
I have an application, which requires several SQL activities, so I wrap
them in a transaction:
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitt ed);

I use MS Application Block for Data Access to handle all SQL statements:
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);

I have following 2 problems:
1) When I debug this application from my local machine, in the middle of
this transaction, I cannot use my Sql Query Analyzer to do anything against
some tables used in this transaction, even though I set transaction's
isolation level to read uncommitted. Until I finish my debugging, result
will return from query analyzer.

2) I have a common class, and it contains a function shared by some other
functions,
public bool Audit(SqlTransaction tran) {
string sql = "insert into AuditTable ....";
try {
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);
return true;
} catch (Exception ex) {
return false;
}
}
Every other function passes its own transaction object to this function.
I frequently find dead lock caused by sql statement in this function. Is
there any limitation to use transaction object across classes? The other
funny thing is, the audit table is used to be inserted only, no other piece
of code will read/write to this table, so how comes this relative
independent table will cause dead lock?

Welcome to any comment.

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 17 '05 #1
3 6811
Hi Hardy,

Check IsolationLevel property after you opened transaction. Is it still
ReadUncommited after transaction was opened?
--
Val Mazur
Microsoft MVP

http://xport.mvps.org

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi all,
I have an application, which requires several SQL activities, so I wrap
them in a transaction:
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction tran =
conn.BeginTransaction(IsolationLevel.ReadUncommitt ed);

I use MS Application Block for Data Access to handle all SQL
statements:
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);

I have following 2 problems:
1) When I debug this application from my local machine, in the middle of
this transaction, I cannot use my Sql Query Analyzer to do anything
against some tables used in this transaction, even though I set
transaction's isolation level to read uncommitted. Until I finish my
debugging, result will return from query analyzer.

2) I have a common class, and it contains a function shared by some other
functions,
public bool Audit(SqlTransaction tran) {
string sql = "insert into AuditTable ....";
try {
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);
return true;
} catch (Exception ex) {
return false;
}
}
Every other function passes its own transaction object to this
function. I frequently find dead lock caused by sql statement in this
function. Is there any limitation to use transaction object across
classes? The other funny thing is, the audit table is used to be inserted
only, no other piece of code will read/write to this table, so how comes
this relative independent table will cause dead lock?

Welcome to any comment.

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 17 '05 #2
Yes, I am sure isolation level is still ReadUncommitted.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Val Mazur (MVP)" <gr******@hotmail.com> wrote in message
news:OG****************@TK2MSFTNGP12.phx.gbl...
Hi Hardy,

Check IsolationLevel property after you opened transaction. Is it still
ReadUncommited after transaction was opened?
--
Val Mazur
Microsoft MVP

http://xport.mvps.org

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi all,
I have an application, which requires several SQL activities, so I
wrap them in a transaction:
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction tran =
conn.BeginTransaction(IsolationLevel.ReadUncommitt ed);

I use MS Application Block for Data Access to handle all SQL
statements:
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);

I have following 2 problems:
1) When I debug this application from my local machine, in the middle of
this transaction, I cannot use my Sql Query Analyzer to do anything
against some tables used in this transaction, even though I set
transaction's isolation level to read uncommitted. Until I finish my
debugging, result will return from query analyzer.

2) I have a common class, and it contains a function shared by some other
functions,
public bool Audit(SqlTransaction tran) {
string sql = "insert into AuditTable ....";
try {
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);
return true;
} catch (Exception ex) {
return false;
}
}
Every other function passes its own transaction object to this
function. I frequently find dead lock caused by sql statement in this
function. Is there any limitation to use transaction object across
classes? The other funny thing is, the audit table is used to be inserted
only, no other piece of code will read/write to this table, so how comes
this relative independent table will cause dead lock?

Welcome to any comment.

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy


Nov 17 '05 #3
Then it looks like a bug. I will try to check if this the same on my PC

--
Val Mazur
Microsoft MVP

http://xport.mvps.org

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:up**************@TK2MSFTNGP14.phx.gbl...
Yes, I am sure isolation level is still ReadUncommitted.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Val Mazur (MVP)" <gr******@hotmail.com> wrote in message
news:OG****************@TK2MSFTNGP12.phx.gbl...
Hi Hardy,

Check IsolationLevel property after you opened transaction. Is it still
ReadUncommited after transaction was opened?
--
Val Mazur
Microsoft MVP

http://xport.mvps.org

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi all,
I have an application, which requires several SQL activities, so I
wrap them in a transaction:
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction tran =
conn.BeginTransaction(IsolationLevel.ReadUncommitt ed);

I use MS Application Block for Data Access to handle all SQL
statements:
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);

I have following 2 problems:
1) When I debug this application from my local machine, in the middle of
this transaction, I cannot use my Sql Query Analyzer to do anything
against some tables used in this transaction, even though I set
transaction's isolation level to read uncommitted. Until I finish my
debugging, result will return from query analyzer.

2) I have a common class, and it contains a function shared by some
other functions,
public bool Audit(SqlTransaction tran) {
string sql = "insert into AuditTable ....";
try {
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);
return true;
} catch (Exception ex) {
return false;
}
}
Every other function passes its own transaction object to this
function. I frequently find dead lock caused by sql statement in this
function. Is there any limitation to use transaction object across
classes? The other funny thing is, the audit table is used to be
inserted only, no other piece of code will read/write to this table, so
how comes this relative independent table will cause dead lock?

Welcome to any comment.

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
0
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
3
by: Mike P | last post by:
I am using transactions on my website and the Isolation Level is ReadCommitted. Since the website has a lot of traffic this may be causing it to lock up every now and again. Can somebody tell...
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
6
by: Gidi | last post by:
Hi, I want to call a stored procedure that is in my SQL DataBase and i want to do it with transaction so i could roll-back in case of need. if i do a simple SP (like select * from table) and i...
2
by: Beenz | last post by:
Hello, I am developing an application in C#, which was previously in .Net 2005 Beta, then it was working perfectly fine, but from the time I have upgraded it to .Net 2.0 Professional, its...
5
by: ashley.ward | last post by:
I am attempting to write a program with VB 2005 Express Edition which accesses an Oracle 9 database and dumps the results of three SELECT queries into a spreadsheet file once every hour. ...
0
by: cristo | last post by:
I, After reading all what I could find I have some question about transaction and connection pooling. Let`s look at an example : Dim _transOpt As TransactionOptions...
11
by: Jialiang Ge [MSFT] | last post by:
Hello Peter, I once came across the same error "ExecuteReader requires the command to have a transaction when the connection assigned? with running two threads talking with the database. There...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.