Re: SqlDataReader.Close() bug?

From: Miha Markic [MVP C#] (miha)
Date: 07/30/04


Date: Fri, 30 Jul 2004 20:45:29 +0200

Hi Bill,

"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
news:eKuZv7ldEHA.3792@TK2MSFTNGP09.phx.gbl...
> This makes sense. You did not cancel the operation. First, you asked for
> 100,000 gallons of water to be pumped into a tank. You opened the spigot
and
> took out a couple of gallons and then said forget it.
>
> The server does not know you don't want the rest of the rows. You need to
> use Command.Cancel first, then close the DataReader. I expect the server
is
> still fetching rows and ADO.NET is flushing them.

I am not sure if this is the case because:
a) it really shouldn't just exit the application
b) this ugly piece of code works just fine (note that there are more than
two records)
sqlConnection1.Open();

SqlCommand cmd = new SqlCommand("SELECT * FROM Orders", sqlConnection1);

SqlDataReader rdr = cmd.ExecuteReader();

bool res = rdr.Read();

res = rdr.Read();

rdr.Close();

sqlConnection1.Close();

Well, just my feeling.

-- 
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com


Relevant Pages

  • Re: SqlDataReader.Close() bug?
    ... Cancelcan help in some scenarios. ... >> took out a couple of gallons and then said forget it. ... >> The server does not know you don't want the rest of the rows. ... > bool res = rdr.Read; ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SqlDataReader.Close() bug?
    ... took out a couple of gallons and then said forget it. ... The server does not know you don't want the rest of the rows. ... > This error occurrs after selecting 275,000 records then exiting after ... > static void Main(stringargs) ...
    (microsoft.public.dotnet.framework.adonet)