W
Walid Magd
Hi everyone
My understanding is that DataReader is connected object. So can some one
please help me explaining this behavior?
Few iterations down in this loop, I stoped my SQL Server services and the
code continued to work
SqlDataReader oDataReader = cmd.ExecuteReader();
while(oDataReader.Read() )
{
Console.WriteLine(oDataReader["CustomerID"] + " - " +
oDataReader["CompanyName"]);
}
cn.Close();
On the other hand, if I moved the cn.Close() to just right after
cmd.ExecuteReader();
I get the expected unhandled exception.
What is going on? What is the difference between closed and broken
connection?
My understanding is that DataReader is connected object. So can some one
please help me explaining this behavior?
Few iterations down in this loop, I stoped my SQL Server services and the
code continued to work
SqlDataReader oDataReader = cmd.ExecuteReader();
while(oDataReader.Read() )
{
Console.WriteLine(oDataReader["CustomerID"] + " - " +
oDataReader["CompanyName"]);
}
cn.Close();
On the other hand, if I moved the cn.Close() to just right after
cmd.ExecuteReader();
I get the expected unhandled exception.
What is going on? What is the difference between closed and broken
connection?