Loopback59 / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Issue connecting to SQL Server 2008 R2 Express #281

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output? What do you see instead?
======================================================
I cannot connect to my local instance of SQL Server. Here are 2 variations of 
connection string that i used along with their output

>>> cnxn= pyodbc.connect('DRIVER={SQL 
Server};SERVER=127.0.0.1;DATABASE=master;UID=guddu;PWD=ABC')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server 
Driver][DBNETLIB]General network error. Check your network documentation. (11) 
(SQLDriverConnect);[01000] [Microsoft][ODBC SQL Server 
Driver][DBNETLIB]ConnectionOpen (PreLoginHandshake()). (233)')
>>> cnxn= pyodbc.connect('DRIVER={SQL 
Server};SERVER=localhost;DATABASE=master;UID=guddu;PWD=ABC')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server 
Driver][DBNETLIB]SQL Server does not exist or access denied. (17) 
(SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server 
Driver][DBNETLIB]ConnectionOpen (Connect()). (52)')
>>>

What version of the product are you using? On what operating system?
====================================================================
pyODBC 3.0.6, Python 2.7, Windows XP, SQL Server 2008 R2 Express

Original issue reported on code.google.com by anurag.c...@gmail.com on 10 Aug 2012 at 6:15

GoogleCodeExporter commented 9 years ago
I use pyodbc with SQL Server 2008 R2 daily, so I'm confident it works in 
general.

There are two common issues I think will answer your question:

1) The first is that SQL Server Express doesn't use the default instance name, 
so you must provide it as part of the SERVER keyword.  Something like: 
Server=127.0.0.1\SQLEXPRESS

2) I believe R2 does not enable TCP/IP by default, so make sure you check the 
SQL Server protocols and enable them.

(And don't forget to check your firewall ;)

Original comment by mkleehammer on 17 Aug 2012 at 2:05