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 call a WCF service using soap in IE8 and I can't
I am trying to call c# function from javascript the code i have tried
I am trying to work out if I need to call close on a
'm trying to call a server side function in nested jquery dialogs the design
i am trying to call a server side button click method from javascript function
i have been trying to call a PHP script with the android system. i
I tried to call this method from multiple threads trying to get the ID
function close() { console.log('close'); $(#display).hide(); } I am trying to call a closefunction when
On the server side, I'm trying to gracefully close a connected socket. I know
Working with C# in .NET, I am trying to call IActiveScript.Close on my instance

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.