ODBC SQL Server Driver Login timeout expired

て烟熏妆下的殇ゞ 提交于 2021-02-07 18:26:29

问题


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:


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/37071716/odbc-sql-server-driver-login-timeout-expired

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!