Friday, July 15, 2016

(Solved) Error: Changes to the state or options of database '' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

Error:

Changes to the state or options of database '' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

Solution:


ALTER DATABASE [dbname] set multi_user

SELECT request_session_id FROM sys.dm_tran_locks 
WHERE resource_database_id = DB_ID('[dbname]')

KILL [session_id]

(Solved) Error: Exclusive access could not be obtained because the database is in use

Error:

Exclusive access could not be obtained because the database is in use

Solution:


USE MASTER;
ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

Friday, April 22, 2016

Avoid opening same url tab again using JavaScript

The second parameter of window.open() provides the name of the window or tab to open it in. If you use '_blank' then it will always open in a new window. If you specify a value that doesn't start with an underscore and a window or tab already exists with that name then the page will be loaded in that existing window or tab. The fourth parameter can be set to true or false to indicate how the existing history associated with that window or tab should be treated.

So here the second param I have passed is the same URL as I consider it as unique.

var url = 'http://your_url';
window.open(url, url);