• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

Timeout expired with SQL Server query

When running a stored procedure from my asp.net application I recieve the following error:
System.Data.SqlClient.SqlException: Timeout expired

The command object timeout property is set to the default of 30.

However when I run the same stored procedure in Query Analyzer it only take 6 seconds to complete.

What, other than the time it takes to execute the query, would cause a "timeout expired" error.
  • 2
1 Solution
Most likely your database is locked
restart your sql service and see if that happens
that can also open if you keep opening connections without closing them in your code. always check for the connection status before you open it

esc7Author Commented:
i restarted the service but no change.
i also checked to make sure that i am opening and closing a single connection... still no change.
Try to run sp_who2 from query analyzer while you are attempting to run this app and see if anything is blocking you
also make sure to setsqlcommand.timeout after you open your connection see if that makes a difference

Good luck
an infinite loop can also cause a timeout expired error... Maybe you can post the query here...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now