Not sure what you mean. The script you are showing is located in FieldChange, not in CanPost.
What error are you getting? A syntax error?
Don't set TDConnection to Nothing. TDConnection is your session object that is running when you log in to QC. If you have a variable pointing to it you can set that variable to Nothing, but not the object itself.