Whenever I try the following, the reader that is returned is always
closed. What am I missing ?
When I look at the reader in the ExecuteReader, it is fine. THen it
gets closed on the returm.
Thanks!
============================
public void Test()
{
IDBGateway gateway = new
DBGateway(ConnectionChoice.DOM);
using (IDataReader reader =
gateway.ExecuteReader( Utility.GroupSql,null))
{
while (reader.Read())
{
Debug.WriteLine(reader[0].ToString());
}
}
}
===================
Gateway code: ( and all of the factory stuff is fine )
public IDataReader ExecuteReader(string selectStatement,
IDataParameterCollection parameters)
{
try
{
using (IDbConnection connection =
factory.CreateConnection())
{
IDbCommand command = connection.CreateCommand();
command.CommandText = selectStatement;
command.CommandType = CommandType.Text;
try
{
connection.Open();
}
catch
{
throw;
}
IDataReader reader =
command.ExecuteReader( CommandBehavior.CloseConnection);
return reader;
}
}
catch
{
throw;
}
}