How to limit the number of sessions for a specific login How can we let just one program to connect to the database, in case many programs have the connection string.
(limit the number of sessions for a specific login)
If all programs are using the same credentials in the connection string, you might be able to achieve what you're after by using a Logon Trigger to limit the number of sessions for a specific login. For example, in the following code (taken from the documentation), the logon trigger denies log in attempts to SQL Server initiated by login login_test if there are already three user sessions created by that login. 

USE master;  
GO  
CREATE LOGIN login_test WITH PASSWORD = '3KHJ6dhx(0xVYsdf' MUST_CHANGE,  
    CHECK_EXPIRATION = ON;  
GO  
GRANT VIEW SERVER STATE TO login_test;  
GO  
CREATE TRIGGER connection_limit_trigger  
ON ALL SERVER WITH EXECUTE AS 'login_test'  
FOR LOGON  
AS  
BEGIN  
IF ORIGINAL_LOGIN()= 'login_test' AND  
    (SELECT COUNT(*) FROM sys.dm_exec_sessions  
            WHERE is_user_process = 1 AND  
                original_login_name = 'login_test') &gt; 3  
    ROLLBACK;  
END;