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 47609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:08:58+00:00 2026-05-10T16:08:58+00:00

When trying to call Close or Dispose on an SqlDataReader i get a timeout

  • 0

When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with:

String CRLF = '\r\n'; String sql =      'SELECT * ' + CRLF +     'FROM (' + CRLF +     '   SELECT (a.Number * 256) + b.Number AS Number' + CRLF +     '   FROM    master..spt_values a,' + CRLF +     '       master..spt_values b' + CRLF +     '   WHERE   a.Type = 'p'' + CRLF +     '       AND b.Type = 'p') Numbers1' + CRLF +     '   FULL OUTER JOIN (' + CRLF +     '       SELECT (print('code sample');a.Number * 256) + b.Number AS Number' + CRLF +     '       FROM    master..spt_values a,' + CRLF +     '           master..spt_values b' + CRLF +     '       WHERE   a.Type = 'p'' + CRLF +     '           AND b.Type = 'p') Numbers2' + CRLF +     '   ON 1=1';  DbCommand cmd = connection.CreateCommand(); cmd.CommandText = sql; DbDataReader rdr = cmd.ExecuteReader(); rdr.Close(); 

If you call reader.Close() or reader.Dispose() it will throw a System.Data.SqlClient.SqlException:

  • ErrorCode: -2146232060 (0x80131904)
  • Message: ‘Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.’
  • 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. 2026-05-10T16:08:59+00:00Added an answer on May 10, 2026 at 4:08 pm

    it’s because you have just opened the data reader and have not completely iterated through it yet. you will need to .Cancel() your DbCommand object before you attempt to close a data reader that hasn’t completed yet (and the DbConnection as well). of course, by .Cancel()-ing your DbCommand, I’m not sure of this but you might encounter some other exception. but you should just catch it if it happens.

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

Sidebar

Related Questions

I'm trying to get a cross domain call to work using JSONP within JQuery.
Been trying to call Preferences.java class using: Intent settingsActivity = new Intent(getBaseContext(), Preferences.class); startActivity(settingsActivity);
I am trying to make condition to call chain function in Jquery. I used
I am trying to get JsTree to work to get a folder view in
I am trying to close an open dialog at the end of a function
I am trying to block the unload event for a page until I get
I m trying to delete a record from a SQLiteDB via Android Application,This is
I have a simple WCF service that i'm communicating with Asynchronously. The thing i
i'm writing program for Nokia 5230 (S60 5th edition platform) using Nokia Qt SDK.
After getting fed up with c3p0's constant locking I'm turning to BoneCP for an

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.