Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODBC SQL Server Driver Login timeout expired

I'm failing to connect to a SQL server SQLExpress. The connection worked fine a few days ago. This is how I tried to connect (I'm using Microsoft SQL server management studio):

connection = pyodbc.connect("DSN=sqlServer; UID=myuser;PWD=mypassword") 
cursor = connection.cursor()

The error I get:

('HYT00', '[HYT00] [Microsoft][ODBC SQL Server Driver]Login timeout expired (0) (SQLDriverConnect)')

In the ODBC Data Source Administrator, when I test the data source I get:

enter image description here

like image 331
user5435739 Avatar asked Dec 18 '22 17:12

user5435739


2 Answers

I got the similar issue.

The problem was actually I was using "SQL Server" as the driver in my ODBC settings in my DSN.

The driver should be "SQL Server Native Client 11.0".

It fixed the issue for me.

like image 84
Satish Kumar Avatar answered Dec 28 '22 09:12

Satish Kumar


Because you are having the same issue in the ODBC Data Source Administrator I would try to focus on that first not on your code.

Here you can find a list with possible problems

Maybe this can help you find out what the problem is.

I also would try to connect with the SQL Server Management Studio. Maybe it is possible to connect with a different user or via Windows login. That would mean that your user might not exist anymore (maybe because you renewed tha database or something).

Also I sometimes have the problem that the SQL Server is not started either locally or on the server. Maybe you could check if the service is started and the database is running.

like image 21
Xamm Avatar answered Dec 28 '22 10:12

Xamm