Does a connection made to the database get closed automatically when a call to the repeater's databind method is made?
here is the code snippet contained within a wrapper class method to the ent. lib.
public SqlDataReader RunQuery(string strQuery)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = strQuery;
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
return (SqlDataReader)db.ExecuteReader(dbCommand,CommandBehavior.CloseConnection);
}
The presentation layer calls the wrapper class's method containing the above code like this
SQLwrap sr = new SQLwrap();
Repeater1.DataSource = sr.RunQuery("select ....");
Repeater1.DataBind();
is this the right way to do it?
I think I read somewhere long ago that the repeater.databind automatically closes the connection, but Im not sure about it now.
OK, if it does close the connection, then in the case where its not a repeater, how does one ensure that the connection has been closed?
Thanks.