i don't know which problem you are running into when trying to set the DB in single user mode... but usually this would work
ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
and to let people back on...
ALTER DATABASE dbname SET MULTI_USER
you can also use sp_dboption as shown below, but the proc is deprecated since 2000 or 2005... can't recall
sp_dboption 'dbname', 'single user', 'true'
sp_dboption 'dbname', 'single user', 'false'