Dead Locks beacuse of SqlConnection Open.

V

vineet batta

Hi ,


I am facing some dead lock problem.
My Application is spawning threads(MAX of 5) and on each
thread i am calling stored procedure which updates a row.

1)There are times when there are no records .. so all the
threads are opening and closing and checking for the some
vales before calling update.This is case when there are
no records in the table.

2)But i get dead locks when there are lot of records in
the table.

Can the situation 1 that is 5 connections open
(SqlConnection.Open()) have on any affect on sitaution 2.

Pl share ur thougth around it.

thanx in advance.

Vineet Batta
 
C

Cowboy \(Gregory A. Beamer\)

The first thing I would do is run the app with SQL profiler working to get
an idea of what command is deadlocking. The next step is to examine locking
strategies on your command objects and see if you can alter this without
sacrificing data integrity. If this is impossible, you might want to move
your data manipulation to one thread to avoid locks.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
C

Cowboy \(Gregory A. Beamer\)

Deadlocks occur when one connection locks records that another connection
needs. If this is the same stored procedure, you may need to change the
locking strategy from default. In addition, be sure you are closing, and
preferably disposing, connections when you are finished with them. DO NOT
let .NET clean up your mess on such an expensive resource, as you are just
asking for trouble.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
W

William \(Bill\) Vaughn

Gregory might be on to something here. But unless you turn of connection
pooling your connections will still hang around in the pool after you close
them--even if you dispose the objects.


--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top