This problem can occur because of both software and hardware, in case of hardware, dead battery is one cause.
The other cause that I have faced, is damaged charging circuit and that is the worst, so find a good mechanic,else new mother board will be needed.
I my case that problem occurred because I had used a low quality charger.
solved Dell Inspiron N1050 Battery Plugged In Not Charging [closed]