i found out the answer. Two things need to be done :
- The STM8S IC requires electrolytic capacitor from 0.47uF to 3.3uF to be connected between its VCAP and ground pin.
- External 5V power supply should be given to VDD and GND pins of SWIM connector of ST Link v2 programmer. Also, thses VDD and GND pins of SWIM connector should be connected to VDD and GND pin of STM8S IC.
After following these two extra step, I can now easily program the STM8S003F3 IC.