i have a problem:
i am using .net core 3.1 WPF Application to connect to MSSQL SERVER 2016. The Code:
SqlConnection conn = new SqlConnection("Server=MYSERVERNAME\\SQLEXPRESS;Database=MYDB;User ID=dbRead;Password=myPASSWORD;");
conn.Open();
i searched a lot and found this: https://github.com/dotnet/SqlClient/issues/367
After a while i get a timeOut exception so i added Connect Timeout=60
and now the connection can be established, but maybe after >20 seconds.
The Server has also an old version of MSSQLSERVER installed 2012.
(Because we upgraded from 2012 to 2016)
This version has the instance MSSQL and with this instance and the same connection string (MYSERVERNAME\\MSSQL
) i have no issues.
If iam using a .netframework application no error occures.
So i dont know what i have to do?
Maybe somebody had the same problem.
Thanks
UPDATE: After some research i found this:
Dot net Core – How to fix: TimeOut-Error to MSSQL 2017 (which does not happen with .Net 4.7.1)
Forcing to use named pipes by specifying np: qualifier in the server parameter in the connection string does the job
SqlConnection conn = new SqlConnection("Server=np:xxx.xxx.xxx.xxx\\SQLEXPRESS;Database=MYDB;User ID=dbRead;Password=myPASSWORD;");
conn.Open();