How can i add thumbnails images to particular post (using code not admin pannel) in wordpress

First you’ll need to upload the image, like this. This will upload the image and add a row to wp_posts where your attachment is.

How dynamic do you need this to be? Can you upload the image with the user interface or does that have to be done programatically as well?

In your case, the third parameter of update_post_meta() should be the ID of the image in the wp_posts table.

Edit: This is more what you need regarding the image upload: How to add image to post programmatically?.