我有一个在 VPS 上运行的 MS SQL Server 2005 Express。我在 Python 中使用 pymssql 通过以下代码连接到我的服务器:
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,但没有运气。谁能指出我在这里缺少的东西?
谢谢!