PC Review


Reply
Thread Tools Rate Thread

Database Blocking Redux

 
 
Jonathan Wood
Guest
Posts: n/a
 
      22nd Jan 2009
Based on my other thread, "Database Blocking -- Why?" I wonder if I could
ask a few specific questions from someone who understands ADO/SQL better
than I.

1. When reading rows using SqlDataReader, does reading the next row release
the lock on the previous row? It sounds like the answer is no because
several rows may be locked at a time. Could someone confirm?

2. How about DataSet? Is there a way to ensure any locks on the rows I've
read get released?

Thanks.

Jonathan

 
Reply With Quote
 
 
 
 
William Vaughn \(MVP\)
Guest
Posts: n/a
 
      23rd Jan 2009
SQL Server stores rows on pages and pages on extents. Given the number of
locks to manage, it's rare for SQL Server to lock individual rows.
Ordinarily (depending on the query intent), pages are locked. A page is 8K
so it might contain several (dozen, hundred or thousand) rows. If SQL Server
finds there are too many pages locked, it escalates locks to the entire
extent and then to the entire table.

Once the rowset population is complete--the Fill method is has completed or
DataReader.Read returns False, any share locks are released. The Dataset is
always a "disconnected" set of data that can exist without benefit of a
Connection. Unlike ADO classic (COM-based ADO) where one created server-side
or updatable cursors, ADO.NET has no mechanism to hold rows on the server
with (at least) one exception--when you execute a query with a
Repeatable-Read Transaction. In this case, the entire rowset is locked until
the transaction is committed.

I discuss these operations at length in my book.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________



"Jonathan Wood" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Based on my other thread, "Database Blocking -- Why?" I wonder if I could
> ask a few specific questions from someone who understands ADO/SQL better
> than I.
>
> 1. When reading rows using SqlDataReader, does reading the next row
> release the lock on the previous row? It sounds like the answer is no
> because several rows may be locked at a time. Could someone confirm?
>
> 2. How about DataSet? Is there a way to ensure any locks on the rows I've
> read get released?
>
> Thanks.
>
> Jonathan
>

 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      23rd Jan 2009
"William Vaughn (MVP)" <(E-Mail Removed)> wrote in message
news:9F503C73-3C77-40E0-9572-(E-Mail Removed)...

> Once the rowset population is complete--the Fill method is has completed
> or DataReader.Read returns False, any share locks are released.


Cool. That latter approach seems to be the one I'm zeroing in on.

Thanks.

Jonathan

 
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
Database Blocking Ragid Microsoft C# .NET 1 28th Jul 2009 12:47 PM
Database Blocking -- Why? Jonathan Wood Microsoft ADO .NET 30 23rd Jan 2009 11:41 PM
How do I get admin access to the database after blocking myself o. =?Utf-8?B?TWluaS1tZQ==?= Microsoft Access 1 27th Jan 2005 01:26 PM
ASPState SQL Database Blocking Ross Microsoft ASP .NET 0 3rd May 2004 06:35 PM
Blocking Access to the back end of a split database Mark Microsoft Access Security 1 25th Oct 2003 06:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:33 AM.