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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With