Can't connect to SQL Server 2005 Express from an ASP.NET C# page
- by Aviv
Hey guys,
I have an MS SQL Server 2005 Express running on a VPS.
I'm using pymssql in Python to connect to my server with the following code:
conn = pymssql.connect(host='host:port', user='me', password='pwd', database='db')
and it works perfectly.
When I try to connect to the server from an ASP.NET C# page with the following code:
SqlConnection myConnection = new SqlConnection("Data Source=host,port;Network Library=DBMSSOCN; Initial Catalog=db;User ID=me;Password=pwd;");
myConnection.Open();
When I run the ASP.NET page I get the following exception at 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.)
I tried restarting the SQL Server but I had no luck.
Can anyone point me out to what I'm missing here?
Thanks!