Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 444303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:15:25+00:00 2026-05-12T21:15:25+00:00

i seem to be getting a lot of this in my Linq 2 SQL

  • 0

i seem to be getting a lot of this in my Linq 2 SQL

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

There is really no reason for it, its a simple query that returns 1 record.

I was thinking about opening my datacontext within a Using statement on each method that needs it, i currently am using a private module level variable to open the datacontext..

Is this recommended?

I don’t see why it would be timing out, i can only think that i have too many data contexts around….

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:15:26+00:00Added an answer on May 12, 2026 at 9:15 pm

    The datacontext is designed to be opened when you use it, and then thrown away. For example:

    using (var dc = new MyDataContext())
        dc.sp_DailyJob();
    

    Right after the using block, the datacontext is released back to the connection pool.

    Now, if you cache a DataContext in a local module, it might go unused for a while. Then SQL Server will eventually close your connection because it’s idle for too long. The next call generates the Timeout expired message.

    I’d remove the caching of the DataContext, and keep create a new DataContext for every call or query you run. Dispose them as soon as you can. There’s no performance overhead in that, because the connections are cached by a highly optimized connection pool.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I researched a lot on this and seem to be getting conflicting answers on
I seem to be getting this particular always when i am trying to receive
I've been coding for a while now but seem to be getting this issue
Spent a good few hours on this now and don't seem to be getting
This may seem like a simple question but i am getting an error when
I am having a lot of trouble getting m core data objects to be
I'm having a lot of trouble getting data out of pig and into a
I seem to be getting this error message: (a:ActionNotSupported) The message with Action 'GetServices'
This is a really nebulous error that I can't seem to get a lot
I keep getting a memory leak indication from this sql statement when I assign

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.