我有一臺運行在VPS上的MS SQL Server 2005 Express。 我使用pymssql在Python用下面的代碼連接到我的服務器:無法從ASP.NET C#頁面連接到SQL Server 2005 Express
conn = pymssql.connect(host='host:port', user='me', password='pwd', database='db')
和它完美的作品。 當我嘗試從ASP.NET C#頁面下面的代碼連接到服務器:
SqlConnection myConnection = new SqlConnection("Data Source=host,port;Network Library=DBMSSOCN; Initial Catalog=db;User ID=me;Password=pwd;");
myConnection.Open();
當我運行ASP.NET頁面我得到myConnection.Open(以下除外);:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
我試過重新啓動SQL Server,但我沒有運氣。 任何人都可以指出我在這裏錯過了什麼嗎?
謝謝!
是問題啓動服務器或連接到它?我確定希望你的代碼中沒有實際的「host ='host:port'」。嘗試使用'sqlcmd'命令提示符連接到服務器 – m0s 2010-05-20 08:38:56
嘗試一個備用連接字符串,請參閱:http://www.connectionstrings。 com – 2010-05-20 08:43:03
你有沒有找到解決這個問題的方法?我遇到了同樣的問題 – 2012-03-15 15:33:35