private void checkFinishedMatches(DateTime from, DateTime to) { using (OracleConnection connection = new OracleConnection(connString)) { connection.Open(); String query = "SELECT idMatch FROM Match WHERE Finished = 'n' AND DateMatch <= (TO_DATE('" + to.Month + "/" + to.Day + "/" + to.Year + "', 'mm/dd/yyyy')) ORDER BY idMatch"; OracleCommand command = new OracleCommand(query, connection); command.CommandType = CommandType.Text; OracleDataReader reader = command.ExecuteReader(); while (reader.Read()) { int idMatch = reader.GetInt32(0); PlayTheMatch ptm = new PlayTheMatch(FormLogin.docMain, idMatch); } } }