private void DeleteOldData() { SqlDataReader dataReader = null; try { List <string> deleteKeys = new List <string>(); // ja - get all of the jobs that are printed and that are at least x minutes old dataReader = SqlCmd.GetOldJobsReader(); // ja - loop through old jobs and add to our list while (dataReader.Read()) { string sKey = dataReader["Label_Key"].ToString(); deleteKeys.Add(sKey); } dataReader.Close(); // ja - there are jobs to delete if (deleteKeys.Count > 0) { Console.WriteLine("Deleting Old Data..."); // ja - loop through list and delete from the serial table first and then the job table foreach (string sKey in deleteKeys) { // ja - delete the rows (not going to worry about the results) SqlCmd.DeleteSerials(sKey); SqlCmd.DeleteJobs(sKey); } } } catch (System.Exception ex) { dataReader.Close(); Config.Log(ex.Message); } }