I have a locally running MS SQL Server 2022 and a C++ project using ODBC API to connect to the database. I'm calling SQLConnect function (https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlconnect-function?view=sql-server-ver16) to initiate the connection and do some DB operations with it. Everything works perfectly fine except that the SQLConnect call always takes more than 2 seconds to complete, while the thread is blocked and just waits for it to return.
I've asked my teammates to test this on their machines and it looks like this issue occurs on about 50% of them - some report also having this >2 seconds delay, while others have almost none (50 ms max). We have identical SQL Server version and configuration - at least as far as I can tell, I could be missing something...
I've already tried different solutions suggested in similar threads, like changing the connection protocols or fiddling with the connection pooling settings, but nothing helped. I also tried using SQL profiler and tracing tool, but did not find anything useful there. Is there anything else I could try to find out why it's happening only on some PCs, and hopefully to "fix" it on mine?
Edit: Answering some questions - I am connecting using Integrated Windows authentication and a defined ODBC DSN (Data Source Name) with local SQL server. This is the exact call I am using:
SQLConnect(connHandle, "MyDSN", 5, NULL, 0, NULL, 0);