开发者

Cant Connect to remote MS SQL server using PYODBC on Windows 7 in Python

So I am having some issues trying to connect to my server that is hosted on 开发者_JAVA技巧my network but on a different computer to the program I am trying to run. I have checked and both computers are on the same domain. I am coding in python and using PYODBC to make the connection. The connect line is as follows:

connectLine = 'DRIVER={SQL Native Client};SERVER='+configValues['host']+';DATABASE='+configValues['db']+';UID='+configValues['user']+';PWD='+configValues['passwd']
db = pyodbc.connect(connectLine)

Now that works when the server is on the same computer as the program, but when I try to connect to the server on my actual server it doesnt work. I am running MicrosoftSQL Express 2005 on Windows SBS 2003 and the computer running the program is running Windows 7 with the program coded in Python 2.7

This is the output of the program, I have it printing the connect line.

DRIVER={SQL Native Client};SERVER=192.168.1.103\OSBORNE;DATABASE=vpmser;UID=massEmailer;PWD=cogbutfeswas5836;
Traceback (most recent call last):
File "E:\Mass Emailer\massEmailer.py", line 56, in <module>
db = pyodbc.connect(connectLine)
Error: ('08001', '[08001] [Microsoft][SQL Native Client]SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].  (-1) (SQLDriverConnectW); [HYT00] [Microsoft][SQL Native Client]Login timeout expired (0); [08001] [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (-1)')


Some possibilities:

(1) About this part of your connection string: SERVER=192.168.1.103\OSBORNE; ... part of the definitely-non-generic error message says """Error Locating Server/Instance Specified"""

A note from connectionstrings.com:

"""Are you using SQL Server 2005 Express? Don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides."""

If OSBORNE is not the name of the remote server, what is it? Why do you include an IP address?

Perhaps you should have OSBORNE\SQLEXPRESS instead of 192.168.1.103\OSBORNE

(2) Down the end of the error message, it says """When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.""" ... Have you checked that (a) SQL Server Express supports remote connections (b) it is configured to allow remote connections?

(3) Can you access the database remotely using (a) a remote logon to the server machine with the userid and password that you are using (b) a query tool that you run on the client machine and uses a DSN to point to the remote machine & database? If so, how do the connection parameters differ from what you have in your connection string?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜