public Hashtable gettestagentkeyvalues(String query) { Dbmethods obj = new Dbmethods(); Hashtable hashKeyValues = new Hashtable(); DataSet ds; try { if (obj.getDs(query, out ds, "dsdt")) { foreach (DataRow dbRow in ds.Tables[0].Rows) { hashKeyValues.Add(dbRow["ID"].ToString(), dbRow["machinename"].ToString()); } } } catch (Exception exception) { Console.Write("Exception occurred while communicating with DB : ==> : " + exception.Message); Console.Write("Query : ==> : " + query); } return(hashKeyValues); }