Thursday, March 29, 2012

Dreaded "SQL Server does not exist or access denied. " Error

I have built a web application that runs on my local web server against my local SQL server and my development server, but now I'm trying to get it to work on the live server and I'm not getting a connection. Whenever I try to open the connection, I get a.

SQL Server does not exist or access denied.

error.

Here is my connection string...

Public connString as string

Dim SQLServerAsString = "xxx.xx.xx.xxx"

connString = "server=" & SQLServer & ";" _

& "database=DBName;Trusted_Connection=No;user id=xxxID;password=xxxPassword;"

myConnection2 =New SqlClient.SqlConnection(connString)

------------------

I'm starting my connection to run a datareader this way...

Dim strSQLAsString

strSQL = "SELECT ClientID, ClientName " & _

"FROM Client; "

' Create a connection to the table in the SQL database located on

' the remote computer.

Dim myCommand2AsNew SqlClient.SqlCommand(strSQL, myConnection2)

myCommand2.CommandTimeout = 1200

myConnection2.Open() 'HERE IS WHERE THE ERROR OCCURS

Dim myReaderAs SqlClient.SqlDataReader = myCommand2.ExecuteReader(CommandBehavior.CloseConnection)

While myReader.Read()

-------------------

I can communicate with the server with no problem from my local computer. I can ping the server, and I also tested it by creating a system DSN using the login and password in my application, and it finds the database with no problem. I've tried to connect using the SQL Server's server name and the IP address and both return the same result. I've also saw something in another post to set the trusted connection parameter to "yes" and that didn't work either.

I'm developing on a Windows XP Professional and I'm trying to connect to a Windows 2003 Server with SQL Server 2000 installed on the machine.

I did add the database by restoring a backup from my local server onto the live server. I don't think that should matter, but maybe it does. If anyone has any ideas, I would greatly appreciate it.

Try adding this to the end of your connection string and see if it makes a difference:
;Network Library =dbmssocn
This will force a TCP/IP connection instead of a named pipes connection.

(fromBUG: Named pipes do not work when worker process runs under ASPNET account)|||Thanks for the suggestion. Unfortunately that didn't work. Could there be some server firewall setting that is preventing the web user account from accessing the server?|||I would also try adding a port number to the end of the IP address:

Dim SQLServerAsString = "xxx.xx.xx.xxx,1433"

And I would remove Trusted_Connection=No completely. Seehttp://www.connectionstrings.comfor connection string examples. If none of that works, perhapsthe user ID and password are incorrect? Sorry, just grasping atstraws. My last recommendation is to review this KB article:Potential causes of the "SQL Server does not exists or access denied" error message. As you'll see, there are a lot of things to check.|||Thanks for your help. It looks like the problem stemmed from a security hole in Windows 2003 Server, which was shutting down the TCP ports. We applied SP4 and it seems to be working for now. Hopefully that's all it was.

No comments:

Post a Comment