The syntax looks OK. Have you tried evaluating @ERROR after the WriteValue attempt?