public static BOEventCollection GetEventsToProcess(int internalStatus, int numberOfEvents) { BOEventCollection a = new BOEventCollection(); SqlConnection con = new SqlConnection(BOBase.GetConnectionString()); con.Open(); try { SqlCommand cmd = new SqlCommand("P_Event_GetEventsToProcess", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@InternalStatus", SqlDbType.Int).Value = internalStatus; cmd.Parameters.Add("@Events", SqlDbType.Int).Value = numberOfEvents; SqlDataReader rdr = cmd.ExecuteReader(); try { while (rdr.Read()) { BOEvent businessObject = new BOEvent(rdr); a.Add(businessObject); } } finally { rdr.Close(); } } finally { con.Close(); } return a; }