Hi
In order to restore a database, you need to have an exclusive access to this database. Which means that you cannot restore a database which is currently in use by other users.
There is a few solutions to avoid this problem :
Perform restore when nobody is using the database...
Kill all spids that are using the database (KILL spid) before restoring
Alter you database to single user mode, perform the restore then reset your database to multi-user mode
Code:
USE master;
GO
ALTER DATABASE yourDb
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
RESTORE ...
GO
ALTER DATABASE yourDb
SET MULTI_USER
GO
Hope this helps