If your adapter isn't working, the first thing you should do is unplug it for a while. Apple's adapters can get quite hot and do have a temperature sensor in them that will shut it off if it overheats. It's not uncommon for adapters to be put in poorly ventilated areas or to get shoved between the cushions of a couch or chair that insulates them and causes them to rapidly heat up.
In addition to heating, some wall circuits might have excessive line noise (voltage spikes and drop-outs) that occur too often for the adapter to manage. These spikes may trigger the adapter's over-voltage protection circuits which, similar to the temperature sensor, will shut off the adapter to prevent damage to the component circuitry.
When these features are triggered they may require time to reset and allow the adapter to work again. Therefore, try unplugging the unit both from the wall and from your computer, and setting it in a cool place for about 5-10 minutes to see if it works again. For poor wall circuits, you can try using another circuit (it may be best to go to a completely different building, such as a public library) or use a uninterruptable power supply (battery backup) to provide a smoother and conditioned power signal to the adapter.
If a battery backup clears the problem, then you may have to continue using it until you can have an electrician clear up the line noise issues you are experiencing.
Beyond these two reasons, the adapter may have poor cabling, which can include broken cables and dirty or corroded contacts. First check the contacts on both the MagSafe connector and on the computer to see if there are any obstructions, since the magnets may pick up odd pieces of metal that might short out the power leads or prevent them from making contact. You might also use a stiff brush to ensure that no dirt has built up in the leads.
For the cabling, while the DC component (that which connects to your computer) is permanently attached to the power supply, the AC component (that which connects to the wall) has the option to use a small plug or an extension cable that Apple provides with the adapter. If you are using one with your setup, try swapping it out for the other to see if you get a working connection. This can be used both to troubleshoot the extension cable, but also to test for better grounding, which can clear up some line noise issues. The small two-prong connector Apple includes with the adapter does not have any grounding connections, but the extension cable does and will provide the internal circuitry with an earth ground, so try using the cable to see if that helps.
The final option for the power supply is its indicator light, which will glow green when supplying power and not charging the battery, and will glow amber when charging the battery. If there are any other colors or behavior such as red lights or blinking lights, then that indicates a problem, even if it's a minor issue. If you are experiencing blinking lights on the power supply, try resetting the system management controller on your computer, which can be done by following the steps in Apple's SMC reset guide.