PC Review


Reply
Thread Tools Rate Thread

A ADO.net Transaction question

 
 
ms
Guest
Posts: n/a
 
      3rd Jul 2008
Hi,
I used SqlTransaction to insert datas to table A in my program ,but I
find that before I commit the transaction ,I even can not use query analyzer
to query data in table A, could anybody tell me why and is it normal or not?

Thanks
-ja


 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      3rd Jul 2008
the transaction carries an "isolation level", which can extend the
duration of locks into the lifetime of the transaction (rather than
just the duration of the individual DML instruction). Essentially,
your transaction has a write-lock on all-or-some of the data in that
table; until the transaction is complete, other spids are (by default)
prevented from even *seeing* the uncertain changes (they could be
rolled back) to prevent phantom/non-repeatable reads.

The caller can blitz through this by adding the (NOLOCK) hint to the
table in the query, but that risks data issues if used
inappropriately.

The exact behavior depends on the exact isolation level - the most
exacting being "serializable".

In SQL server terms, the isolation levels are:
http://msdn.microsoft.com/en-us/library/ms173763.aspx

And the reference from .NET:
http://msdn.microsoft.com/en-us/libr...tionlevel.aspx

Not quite a 1:1 mapping, but close enough.

Marc
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      3rd Jul 2008
ms wrote:
> I used SqlTransaction to insert datas to table A in my program ,but I
> find that before I commit the transaction ,I even can not use query analyzer
> to query data in table A, could anybody tell me why and is it normal or not?


To simplify Marc's explanation: unless you are using transaction
isolation level read uncommitted (which is not the default in SQLServer)
then this is expected behavior.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      3rd Jul 2008
Marc Gravell wrote:
> the transaction carries an "isolation level", which can extend the
> duration of locks into the lifetime of the transaction (rather than
> just the duration of the individual DML instruction). Essentially,
> your transaction has a write-lock on all-or-some of the data in that
> table; until the transaction is complete, other spids are (by default)
> prevented from even *seeing* the uncertain changes (they could be
> rolled back) to prevent phantom/non-repeatable reads.


Technically speaking it is a dirty read he was expecting.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction." Ollie Riches Microsoft C# .NET 3 11th Mar 2005 05:23 PM
"Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction." Ollie Riches Microsoft ADO .NET 3 11th Mar 2005 05:23 PM
Transaction Question..... Frank Microsoft ADO .NET 6 2nd Oct 2004 10:36 AM
Transaction Question Dan Microsoft ADO .NET 3 16th Jun 2004 02:12 PM
Transaction question... Vanessa Microsoft ADO .NET 2 7th Oct 2003 02:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:35 AM.