DeadLock occur while execute SqlDataAdapter.Fill method

343 views
Skip to first unread message

Prashant

unread,
Mar 25, 2008, 10:38:16 AM3/25/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

I am using following code to fill my dataset. when multiple user
connect to the web-site it will give me following error:

Error Message: Transaction (Process ID 98) was deadlocked on lock
resources with another process and has been chosen as the deadlock
victim. Rerun the transaction.

I am using stored procedure to select records from database.

DataSet ds = new DataSet();

SqlConnection mc = OpenSqlConnection();

try

{

SqlCommand cmd = new SqlCommand(strCmd, mc);

cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandTimeout = 0;

if (parameters != null)

{

foreach (KeyValuePair<string, object> p in parameters)

{

cmd.Parameters.AddWithValue(p.Key, p.Value);

}


}

SqlDataAdapter da = new SqlDataAdapter(cmd);

da.Fill(ds);

}

catch (Exception ex)

{

}

finally

{

mc.Close();

}

return ds;



Appreciate your help,

prashant

Jamie Fraser

unread,
Mar 26, 2008, 5:07:28 AM3/26/08
to DotNetDe...@googlegroups.com
There is no transaction in your code, so I assume it must be in your
Stored Procedure? Either that or your using some kind of attribute
based transactional system, but I doubt it.

Post your stored procedure code.

ThanderMaX

unread,
Mar 26, 2008, 2:31:55 AM3/26/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
the exception was thrown from the sql server side.

You can try adding "(nolock)" hint to ur query ... but only if u are
sure what u r doing.
If u need table/row lock , u don't have any way

Shakeel

unread,
Mar 26, 2008, 6:22:09 AM3/26/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Why have you used

cmd.CommandTimeout = 0;

Use
cmd.CommandTimeout = 60;

Bye...
Shakeel
(+919836287255)

Prashant

unread,
Apr 10, 2008, 4:56:02 PM4/10/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
thanks all,

the problem was, nested stored procedure we are calling from asp.net
(c#)
I removed the nested stored porc. call and used embedded SQL while
loading data.

thansk for all your suggestions,
prashant
Reply all
Reply to author
Forward
0 new messages