OK, I eventually got this working by using the code in the original posters link.

Why did the NOP supplied solution not work?
The only thing I can think of is that maybe it isn't accounting for Whitespace in the fields in the database.
The fields in the database were blank but not NULL.
The OP's solution accounted for this.

If others find the official solution not working, maybe this will help.