Re: SqlDataReader.Close() bug?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Chris Gallucci (chris_at_gallucci.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 08:48:30 -0500

OK, my simple sample is returning an error...

<error>
System.Data.SqlClient.SqlException: Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding.
   at System.Data.SqlClient.SqlDataReader.InternalClose(Boolean closeReader)
   at System.Data.SqlClient.SqlDataReader.Close()
   at SqlDataReaderSample.Class1.Main(String[] args) in c:\my
documents\visual studio
projects\sqldatareadersample\sqldatareadersample\class1.cs:line 40
</error>

This error occurrs after selecting 275,000 records then exiting after
reading the first 10...

<codesnippet>
[STAThread]
static void Main(string[] args)
{
    Console.WriteLine("Starting...");
    string sql = "SELECT MyColumn FROM MyTable WHERE MyID <= 275000";
    SqlDataReader rdr = SqlHelper.ExecuteReader(CONN_STRING,
CommandType.Text, sql);
    try
    {
        int i = 0;
        while ( rdr.Read() )
        {
            if ( i++ > 10 ) break;
            Console.WriteLine(rdr.GetString(rdr.GetOrdinal("MyColumn")));
        }
        if ( rdr != null && !rdr.IsClosed )
        {
            rdr.Close();
        }
        rdr = null;
    }
    catch ( Exception ex )
    {
        Console.WriteLine(ex.ToString());
    }
    finally
    {
        if ( rdr != null && !rdr.IsClosed )
        {
            rdr.Close();
        }
    }
    Console.WriteLine("Finished. Press any key to exit.");
    Console.Read();
}
}
</codesnippet>

ChrisG



Relevant Pages

  • errors using BPA
    ... The timeout period ... elapsed prior to completion of the operation or the server is not ... responding. ...
    (microsoft.public.sqlserver.tools)
  • Re: Lost of My site
    ... elapsed prior to completion of the operation or the server is not responding. ... Microsoft.SharePoint.Portal.Data.a.c(SqlCommand A_0, Boolean A_1) ... timeout period elapsed prior to completion of the operation or the server is ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Is this an easy fix or complicated one?
    ... > server; however, the server did not reply within the required timeout period. ... > If the problem continues to occur, contact the program vendor. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Is this an easy fix or complicated one?
    ... server; however, the server did not reply within the required timeout period. ... If the problem continues to occur, contact the program vendor. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Is this an easy fix or complicated one?
    ... >> server; however, the server did not reply within the required timeout period. ... >> If the problem continues to occur, contact the program vendor. ...
    (microsoft.public.windowsxp.help_and_support)