how to avoid [System.Data.SqlClient.SqlException] = {"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not "}
when i will be update the SQL query update join query at time 1000 records in the database at every second. it will be shown this exception.
any one have idea about this exception
thanks in advance. Increase value for Timeout of your SQL Connection & SQL Command
For Connection in Web.Config,
<add key= " ConnectionString" value = " server=(local); uid=sa; password=sa; database=master;Connection Timeout=30" />
For Command,
public void CreateSqlCommand() SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 15 ; cmd.CommandType = CommandType.Text; & also take a look at the following page.
Troubleshooting: Timeout expired [ ^ ]
Free attachment
DBA’s Quick Guide to Timeouts [ ^ ] Increasing the command timeout will solve the problem, but you are addressing the issue rather than the cause
Default query timeout is 30 seconds, so assuming you haven't changed this your queries are taking 30 seconds to run and then reporting timeout.
Can you tune your queries at all?
* Are all tables included in the query correctly indexed. Clustered index on tables etc?
* Have you run your query through Execution Planner? Any areas that could be improved?
* Is only the data you need to update being updated?
You should definitely have a look at the source of the problem first and see if you can improve things here.
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •