<p>For a requirement i was asked to export information into a custom entity that was created in MS CRM 4.0. I am trying to do this programmatically and I have not found a single code that actually accomplishes this. I wrote code to check if a certain value for a field exists in the entity but creating a new entity seems to be a little bit of puzzle for me. Any help on this would be appreciated.</p>

This is my experience when I had a similar requirement in MS CRM 3.0. I started using the CRM sdk to import data but found it was not easy.
Then I ended up using
Scribe adapter for CRM
. It is not free but will easily solve your problem for importing to custom entities. Will post some links on that. need to go through some old bookmarks.
Not sure if this feature exist out of the box for CRM 4.0.