You can use the application role in SQL Server.
It makes no sense for me to block the whole of SQL Server using the login trigger. There may be other databases, and they should also be free, for example, SQL Agent for either Management Studio or the updater ...
If you want to control access to the database, use user roles and applications. According to the Appendix. A role that you should call a single stored procedure from your compiled code, and everything you can do will be determined by the role of the application. If you disable access to other roles and users, no one will be able to access your database ... Other databases can also be configured so as not to grant permissions to other users / roles.
This makes more sense, has no problems with the connection string, and is flexible for other tasks.
Sorry for my English, this is not my native language.
source share