views:

198

answers:

2

Hi Guys,

I Get this error message whenever I tried to up my aspx page.

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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

whic is connected in this connection string

SqlConnection conn = new SqlConnection("Data Source=192.168.xxx.xxx;Initial Catalog=DBSample;User ID=dev;Password=pass;Integrated Security=SSPI;"))

The weird thing is that the server that I'm connecting has already hosting some aspx page. I don't knnow if there's missing in my connectiong string Thanks. and I know the server that I'm connecting to is already allowed remote connection since it's already hosted some aspx websites. :(

Thanks!

+2  A: 

Do you need to add an instance name to your connection string? Do you have the SQLBrowser service running on the target machine, or do you have to specify a port for the instance?

You also get that very same error when the database doesn't exist at the location that you are trying to connect to. Have tried looking at the connection strings of the aspx pages that are successfully connecting?

edited: Specifying Integrated Security=SSPI means you will be using Windows authentication to login to the database. What user is your aspx page running as (check your app pool)? Does it have the rights to log in to the database? This could also explain why it works on one server but not another.

kime waza
Hi Sir, btw I made this project in different server which is successfully running then when I tried to upload it live through IIS it does return that error. Thanks
Sherwin Valdez
Check my edited post.
kime waza
So the problem is in the server? or it's in my connection string?
Sherwin Valdez
kime waza
A: 

Are you trying to connect to a hosted SQL Server over TCP/IP?

The reason I ask is some firewalls block traffic over Port 1433.

If not then it is simply a case of validating the connection string details and ensuring the SQL Server Engine is actually running...

Have you EVER been able to connect to this database from the PC you are currently attempting this connection on?

Simon Mark Smith
I was able to run this project in a different server and when I Upload it in the live server through IIS. I found that error.
Sherwin Valdez
Based on your comment below, I would suggest that you attempt to validate your connection string against the ones that are working on the other ASPX pages.
Simon Mark Smith
Were you running the Project on a different IIS server but still with the same connection string? Or were you pointing to a different SQL Server database also?
Simon Mark Smith
I'm using the same connection string.
Sherwin Valdez
Just to be sure can you connect to this server via SQL Management Studio using the credentials you supplied?
Simon Mark Smith
I don't have a permission in the Server in which the DB is hosted :), so the problem is really in the server?
Sherwin Valdez