It could be as simple as the variable type.

Try this:
 Code:
$Tempname = CStr($rs.Fields.Item("PERSON_CODE").Value)


The CStr() will convert the value to a string, the same as assigning an explicit value in single quotes.