Can't connect to SQL Server 2005 Express from an ASP.NET C# page

Posted by Aviv on Stack Overflow See other posts from Stack Overflow or by Aviv
Published on 2010-05-20T08:31:27Z Indexed on 2010/05/20 9:10 UTC
Read the original article Hit count: 287

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about pymssql

Related posts about sql