The problem is with your SQL, not the code. If you are processing a lot of data, or using tables with a lot of rows, you might need to write your SQL to be more efficient, or implement indexes to speed up data access. Other problems that can give timeouts
are deadlocks which can be monitored via the Activity Monitor.
I am not retreving more records. It will be less than 100.
I am retreving data from table A and B as IEnumerable and storing in Session. Then I bind that Session with ListView. While binding I am again working(retreving data) from table C joining with table A.
Will this do deadlock? Or will this leads to above told error ?
The best way to work on these issues is to use SQL Profiler to trace exactly what is happening, how long things are taking etc. You can copy the sql being sent to your server and paste it into SQL Management Studio and run it direct to see how it performs,
if there are deadlocks, or get SQL Managemenbt Studio to show you the execution plan of the sql too.
And please don't forget to set the CommandTimeOut for the LINQ's generated command's instance such as this below:
using(LinqDataContext dc = new LinqDataContext())
{
dc.CommandTimeOut = your value here;
}
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.commandtimeout.aspx
Marked as answer by joshuait on Aug 22, 2012 07:14 AM
joshuait
Member
65 Points
117 Posts
Timeout expired
Aug 20, 2012 07:22 AM|LINK
Hi all,
I am frequently getting the following error while using LINQ query to fetch data(Not while using Stored Procedure).
My Connection string :
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
My Stack Trace:
Please give your suggestions to avoid this
Joshua
AidyF
Star
9250 Points
1578 Posts
Re: Timeout expired
Aug 20, 2012 07:42 AM|LINK
The problem is with your SQL, not the code. If you are processing a lot of data, or using tables with a lot of rows, you might need to write your SQL to be more efficient, or implement indexes to speed up data access. Other problems that can give timeouts are deadlocks which can be monitored via the Activity Monitor.
joshuait
Member
65 Points
117 Posts
Re: Timeout expired
Aug 20, 2012 08:52 AM|LINK
Hi AidyF,
I am not retreving more records. It will be less than 100.
I am retreving data from table A and B as IEnumerable and storing in Session. Then I bind that Session with ListView. While binding I am again working(retreving data) from table C joining with table A.
Will this do deadlock? Or will this leads to above told error ?
Joshua
AidyF
Star
9250 Points
1578 Posts
Re: Timeout expired
Aug 20, 2012 09:16 AM|LINK
The best way to work on these issues is to use SQL Profiler to trace exactly what is happening, how long things are taking etc. You can copy the sql being sent to your server and paste it into SQL Management Studio and run it direct to see how it performs, if there are deadlocks, or get SQL Managemenbt Studio to show you the execution plan of the sql too.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Timeout expired
Aug 22, 2012 01:18 AM|LINK
Hi,
Please try to change your connetion string to——
Server=.;database=YourDbname;integrated security=sspi
And please don't forget to set the CommandTimeOut for the LINQ's generated command's instance such as this below:
using(LinqDataContext dc = new LinqDataContext()) { dc.CommandTimeOut = your value here; } http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.commandtimeout.aspxraghunandcs
Member
686 Points
163 Posts
Re: Timeout expired
Aug 22, 2012 06:51 AM|LINK
Hi,
Use command.CommandTimeOut=500;
before Executing Query.
Hopes Helps You..........