all groups > sql server programming > january 2007 >
You're in the

sql server programming

group:

Lock question


Re: Lock question Dave Markle
1/25/2007 6:17:05 PM
sql server programming:
Take a look at "System.Transactions.TransactionScope" in the .NET 2.0
Documentation. Since you are using 2 separate connections, you will
have to use a distributed transaction. This means that you need to be
running the Distributed Transaction Coordinator on your ASP.NET box. It
also means that you will pay a possibly significant performance penalty
for doing so.

HTH

-Dave

[quoted text, click to view]


--
-Dave Markle

Re: Lock question Dave Markle
1/25/2007 6:39:02 PM
Ew. It just occurred to me that he is probably doing this in between
ASP.NET *requests*. Yuck.

Erland's right; the solution to your problem (if this is indeed what you
are doing) is: "Don't do this." Even if you find a way to make it
happen (I know the way, but I won't help you shoot yourself in the
foot), it will *kill* your database performance".

-Dave

[quoted text, click to view]


--
-Dave Markle

Re: Lock question Erland Sommarskog
1/25/2007 11:12:39 PM
lord.fist (lord.fist@spam.email.htnet.hr) writes:
[quoted text, click to view]

But why would you disconnect and connect? Yes, this is the common model
with ASP programming, but if you need to keep a transaction alive, you
should also keep the connection open.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Lock question lord.fist
1/25/2007 11:33:47 PM
Hi all,

I have table1 that needs to be locked until some processing is done in
ASP.NET. I know how to lock table but i dont know how address the
transaction.

To sum up. I know i can do this:

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION

//some transaction to do

COMMIT
SET TRANSACTION ISOLATION LEVEL READ COMMITTED


but... I dont know how to keep the lock (keep queries in same
transaction) between 2 reconnects to a SQL Server. So it should be like
this:

ASP.net (abstracted):

SqlCommand("exec somestoredproc",Connection)
Connection.Close
//do some work
SqlCommand("exec somestoredproc2",Connection)
Connection.Close

All the time while ASP.net is doing this table1 needs to be locked for
inserting and updating. Only after execing "somestoredproc2" table1 can
be unlocked. So basicly I need:

//ISOLATE
//BEGIN TRANSACTION
SqlCommand("exec somestoredproc",Connection)
Connection.Close
//do some asp.net work
SqlCommand("exec somestoredproc2",Connection)
Connection.Close
//COMMIT
//RELEASE LOCK

Re: Lock question lord.fist NO[at]SPAM gmail.com
1/26/2007 2:03:00 AM


On Jan 26, 12:39 am, Dave Markle <"dma[remove_ZZ]ZZrkle"@gmail.dot.com>
[quoted text, click to view]

I know all of this but to tell the truth i am using SqlBulkInsert class

and then executing some stored procedure. The thing is they are not
in the same system thread and not even in the same process. So they
should be somewhat organized that bulk inserted table doesn't f*** up
things before everything is ready.
Re: Lock question Erland Sommarskog
1/26/2007 11:31:40 PM
(lord.fist@gmail.com) writes:
[quoted text, click to view]

Sounds that maybe you should use an application lock, probably on
Session level, that the bulkprocess waits for before it jogs along.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button