There is no guarantee of an afterlife. When you're dead, you're dead (See Ecclesiastes 9:5)
Nor, is the resurrection of John 5:28,29 to be considered anything beyond a second chance.
Let's assume for the moment that the bible tells a coherent and true story.
Paul in the NT wrote " I would not have you be ignorant concerning the dead. They sleep." If you accept the legitimacy of the book, any interpretation that makes it contradictory is simply wrong. So if you insist on your interpretation of Ecclesiastes, you must come up with an explanation of how it does not conflict with the NT. and if the dead's very name and memory are gone, how will their name be found in the 'book of life'? And what good would it do if you found it there but they were truly dead?
Soloman's writing spans his whole life and the various stages he went through. The book you cited was during his despondent phase where he was totally bummed out and saw nothing worth while in life. He summed it up by saying "Vanity, vanity, ALL is vanity", so **** it all and just eat, drink and be merry right now because in the end, we're all fucked, and by the way, all women are a bunch of deceiving bitches.' That last part was paraphrased but the meaning is exactly as I said. Do you really want to portray that as the bottom line of what the bible says?
Context is everything and I don't think you or religions have presented it that way.