Timeout expired with SQL Server query

Posted on 2006-05-18
Last Modified: 2008-02-01
When running a stored procedure from my 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.
Question by:esc7
    LVL 27

    Expert Comment

    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


    Author Comment

    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.
    LVL 27

    Accepted Solution

    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
    LVL 3

    Expert Comment

    an infinite loop can also cause a timeout expired error... Maybe you can post the query here...

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now