I figured it out. Your solution, although didn't help me right away, showed me where the problem was occurring and I was able to go from there.
You had the order of the calls to the function GetSQLValueString reversed in your solution.
Thanks for all your help! You saved me much agony.