Cannot connect to SQL server - client side issue - azure-sql-database

I might be the million'th person posting about this, but others' solutions haven't helped me. I have a database on Microsoft SQL Azure. I an trying to connect to it using the Visual Studio 2010's "Connect to Database" Tool.
From my Windows 7 machine, I can connect to it very easily. But from my Windows Server 2008R2 machine i am getting the classic error -
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
All the posts around the web seem to be focussing on the problems on the server side, no one cares if the client goes rogue. :(
Thanks for the replies.

I have seen similar problems with VS2010 DB Tool and Windows Server so I would not suggest try using SSMS 2008 R2 (must be R2). Once you have download SSMS 2008 R2 and configured properly to work on Windows Server it sure will work. In most of the case you really need to open SSMS settings to get it workon on Windows Server.
Next a few points to check:
Verify that the telnet is working from your Windows Server Machine:
c:>telnet _your_sqlazure_database_name.database.windows.net 1433
Disable your real time security and the try again
Finally following the link to keep applying settings in your Windows Server and SSMS which are applicable and I am sure it will work:
http://www.mssqltips.com/sqlservertip/2340/resolving-could-not-open-a-connection-to-sql-server-errors/

One issue is that you need to connect via tcp, not named pipes (per your error message).
Are both servers behind the same firewall (e.g. the same external IP address)? The SQL Azure firewall needs to be configured to allow access from remote IP addresses.

Related

Access MS SQL server remotely

I've been busy going through many of the question asked under the same topic but none of them had solved my problem.
I have MS SQL 2012 standard (trial) is installed on my local PC. Also I have a MS SQL std. server 2005 is installed on a web server (Windows Server 2003) in different domain. Normally I can RDP the web server using the static IP address given by the Infrastructure provider.
Now I wanted to access my MS SQL server installed on the web server using the MS SQL management studio installed on my local PC. but I'm receiving the following error when I try to connect. I tried with the same IP which I used to log in to the server using RDP as the server name.
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
I followed almost everything in this KB. But the windows firewall is disabled on the web server. while I'm waiting for Infrastructure provider to confirm there is no other network level firewall denies access for port:1433, I would like to know are there anything else that I'm missing here?
Problem has been resolved after forwarding the port TCP: 1433 on the router firewall.

SQL Server Express - Connect from remote machine

I have two Win 7 64 bit machines.
On the first one I have installed SQL Server 2008 R2 Express and have no trouble connecting via Management Studio with Windows Auth and also via SQL Auth with a user I set up on the database.
On the second machine I am trying to connect to the database on machine 1 using Management Studio. I'm trying SQL Auth. I therefore obviously also can't connect to it via connection string in my .NET Code
I can ping the first machine from the second.
Things I have tried include the following:
On the machine the database is installed make sure the firewall is allowing connection on Port 1433
Made sure SQL Server service is running
Made sure SQL Server Browser service is running
Created an exception for sqlbrowser.exe in the firewall
Enabled TCP/IP Protocol through SQL Configuration manager
Allowed Remote connections in SQL Server Management Studio
The error I get is:
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
This is the connection string I use in code
Data Source=xxx.xxx.xxx.xxx\sqlexpress;Initial Catalog=dbName;User Id=myUser;Password=myPassword;
This can be caused by a number of reasons but I'm glad my suggestion about checking firewall ports (rather than just allowing a one-way exception for SQL Browser) led you to the answer: the firewall wasn't allowing the correct port # through.
If i remember correctly SQL Server disables remote connections by default.
Please check whether remote connections are enabled and enable them if not:
RMB on Server in Management Studio Object Explorer -> Properties -> Connections -> Allow remote connections...

Cannot connect to localhost SQL Server 2005

I just installed SQL Server 2005 SP2 on Vista and am attempting to connect to my object explorer in Management Studio. When doing so I get the following error:
Cannot connect to localhost.
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: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server) (Microsoft
SQL Server, Error: 2)
I am using the following credentials:
Server type: Database Engine; Server name: localhost; Authentication: Windows Authentication
I am just using SQL Server for a local application. I have tried using 127.0.0.1, my comp name, "." and localhost. I have searched and tried every relevant help topic I could find. I have reinstalled, turned on IIS (just a guess), updated to latest service packs all around, run as admin, etc.
What am I missing here?
JJ
Did you run the User Provisioning Tool for Vista? See KB929907 You may be unable to perform most database operations after you log on to an instance of SQL Server 2005 Express Edition Service Pack 1 on a Windows Vista-based computer
Try using (local)
Also if you have an instance name you can try myComputerName\instanceName
You're missing the instance name. You don't just connect to localhost, but to any of the following (assuming that your machine is called dago and your instance sqlexpress):
localhost\sqlexpress
dago\sqlexpress
.\sqlexpress
I am not using express. It turns out I had a "client" version of SQL Server installed. I didn't even know there was a client version. I ran the full install and added the sa user as Windows Authentication wasn't working for me (next goal). I am connecting via "localhost" (just localhost), so I don't fully understand what the instance suggestion was all about.
Basically the solution was to get the full version installed. My bad. Easy fix.
JJ

Cannot connect to local SQL Server with Management Studio

I'm having an issue with SQL Server, I have 2005 installed on my desktop as well as having SQL Server Management Studio installed..
I've checked and can see "SQL Server (SQLEXPRESS)" started in services.
I've tried to connect to "Local" and "SQLEXPRESS" but both fail to connect.
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: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server) (.Net
SqlClient Data Provider)
Anything else I need to do to connect to it??
UPDATE
I seem to be getting a little further along now. Ive managed to connect to my server with SQL Server Management (FYI .\SQLEXPRESS did the trick) but now im having a issue with my connection string in my web.config
Ive im going to connect to this local sql server using windows authentication how do i need to structure it??
Something like this?
<add name="BensBoxing" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=BritBoxing_Alpha;Integrated Security=False;User Instance=True" providerName="System.Data.SqlClient"/>
This produces a error about
Login failed for user ''.
Check the sql log in the LOG directory of your instance - see if anything is going on there. You'll need to stop the service to open the log - or restart and you can read the old one - named with .1 on the end.
With the error you're getting, you need to enable TCP/IP or Named pipes for named connections. Shared memory connection should work, but you seem to not be using that. Are you trying to connect through SSMS?
In my log I see entries like this...
Server local connection provider is ready to accept connection on [\\.\pipe\mssql$sqlexpress\sql\query ]
As the comments said, .\SQLEXPRESS should work. Also worstationName\SQLEXPRESS will work.
Same as matt said. The "SQL Server(SQLEXPRESS)" was stopped. Enabled it by opening Control Panel > Administrative Tools > Services, right-clicking on the "SQL Server(SQLEXPRESS)" service and selecting "Start" from the available options.
Could connect fine after that.
I was having this problem on a Windows 7 (64 bit) after a power outage. The SQLEXPRESS service was not started even though is status was set to 'Automatic' and the mahine had been rebooted several times. Had to start the service manually.
Try to see, if the service "SQL Server (MSSQLSERVER)" it's started, this solved my problem.
Open Sql server 2014 Configuration Manager.
Click Sql server services and start the sql server service if it is stopped
Then click Check SQL server Network Configuration for TCP/IP Enabled
then restart the sql server management studio (SSMS)
and connect your local database engine

SQL Server 2005 Express - could not open a connection

I installed Microsoft SQL Server 2005 Express edition on my Vista Ultimate computer. However, when it opens I enter my computer name / SQLEXPRESS. When I click the Connect button, it gives me an error message.
Under the configuration tools I cannot find the SQL Server Surface Area Configuration. It only has SQL Server Error and Usage Reporting.
The error message I receive when I click the Connect button is:
A network related or instance specific error occurred while establsihing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that the SQL server is confugured to allow remote connection (provider: Named Pipes Provider, error 40- Could not open a connection to SQL Server) (Microsoft SQL Server : error 67)
From your question, as you'd written, it appears the slash is incorrect. Try:
.\SQLEXPRESS
Also ensure that your SQL Server services are started. Run services.msc and find SQL Server(SQLExpress).
Another thing to check for is the account that the SQL Express service is running under. I think it defaults to network service, but I typically run it under Local System (or if you're feeling ambitious, make a service account for it). This has taken care of a handful of permission issues I've had with SQL Express in the past.