This code does work for a valid user.
Hello Harry,
If it works, then what is the issue with your code?
The other issue is that the error does not appear in the SQL Server log
You can setup SQL Server to log failed login attempts, see Configure Login Auditing (SQL Server Management Studio)
Olaf Helper
[ Blog] [ Xing] [ MVP]