As max Boot wrote:
Far be it from me--a military historian--to dispute the usefulness of history in policymaking. Properly applied, the study of past wars can be essential in guiding the course of current and future conflicts. But the key is to take lessons selectively and intelligently and not become enthralled by lazy reasoning along the lines of "Vietnam was an American war; X is an American war; therefore, X will be another Vietnam."
Indeed, I've addressed this simple fact before:
Any similarities to Vietnam are simply those shared with any war. Well, there is one potential similarity: defeat can be snatched from the jaws of victory by those too dim to see that they can cause defeat--not predict it.
The only relevant comparison between Afghanistan and Vietnam for the purpose of deciding our course of action is that in both cases, there were or are a lot of Americans all too willing to ensure that their predictions of doom and defeat come true.