Jeff,
After a little trouble I have got it working. When I attempted to use it as a SqlCe CommandText string surrounded by inverted commas, I was always getting an error. However, by adding the code copied directly from the web forum page into a multiline textbox it worked fine.
Thank you very much for your help.