M
matt
hello,
when coding a datareader, i often use the following in my code:
conn.Open();
SqlDataReader dr =
command.ExecuteReader(CommandBehavior.CloseConnection);
...[do stuff w/ dr]...
dr.Close()
....with the understanding that, when the reader is closed so will the
connection.
but now im moving my code into a component's static functions. and i
starting wondering: "If i return the datareader to a client
application, will my client app's closure of the returned datareader
close this component's (static function) connection?
like so:
conn.Open();
SqlDataReader dr =
command.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.HasRows)
{
return dr;
}
else
{
return null;
}
....anyone know for a fact?
thanks!
matt
when coding a datareader, i often use the following in my code:
conn.Open();
SqlDataReader dr =
command.ExecuteReader(CommandBehavior.CloseConnection);
...[do stuff w/ dr]...
dr.Close()
....with the understanding that, when the reader is closed so will the
connection.
but now im moving my code into a component's static functions. and i
starting wondering: "If i return the datareader to a client
application, will my client app's closure of the returned datareader
close this component's (static function) connection?
like so:
conn.Open();
SqlDataReader dr =
command.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.HasRows)
{
return dr;
}
else
{
return null;
}
....anyone know for a fact?
thanks!
matt