Adding a SQL connection to Microsoft Visual Studio

  • Hi,

    So I have a server in the cloud with SQL Server installed. I have created a rule on the server's firewall to allow access on port 1433. I have also set the TCP/IP protocol for  IP4 tcp port to 1433 and restarted the sql services.

    But when i try to add a connection in MS visual studio --> View --> SQL Server Object Explorer --> Right CLick SQL Server --> Add SQL Server and i fill in the details (see image attached) i get the attached error. any help would be appreciated

     

    Attachments:
    You must be logged in to view attached files.
  • Can you connect using other tools? The error tells you what is wrong though - Visual studio can't see the server. If I had to guess, I would say firewall, but it could be something like your SQL instance is not listening on port 1433 or Visual Studio is not connecting on port 1433.

    I would personally connect using SSMS first. Make sure that things are good there and if that is good, then start working with other tools. You may need to provide the port or the instance name. If memory serves, port 1433 is the SQL browser port, so that would let you see the instance if you had the instance name included in the server name field, but it won't let the connection go through unless you opened up the firewall for the SQL instance as well.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • ok so i have installed MSSM and tried to connect - but still getting failure. i have tried with the servers IP address and then the ip address:with port number 1433

    SQL connection attempt

    sql error at connection window

    so i have tried for the server name:

    IPADDRESS:1433\SQLEXPRESS

    IPADDRESS\SQLEPRESS

    IPADDRESS

    IPADDRESS:1433

     

     

  • You need a , and not a : for the port split character.

    The error tells me that you probably haven't enabled TCP/IP as a protocol, or there is a firewall in the way which isn't permitting traffic, as its defaulting to named pipes when it needs to be a TCP/IP session.

    As that's on a public IP address I for sure wouldn't want 1433 exposed to the internet, so having it be blocked by a firewall would be something I would do.

    You can try forcing TCP/IP by doing TCP:myipaddress,1433 if you have TCP/IP enabled in configuration manager and the firewall is open, otherwise I would be looking at potentially putting a site2site VPN in place and accessing SQL over the private range instead of the public range.

  • hi ANT Green,

    In the protocols for my SQLEXPRESS  have set IPALL to TCP Port 1433 but still no joy. i have ip2,3,4,5 & 6 - which one shoud i set the ip address on and the TCP port number on?

    I really want to get connected and then look at getting the security sorted.

     

    thank you

    G

     

  • Does it say TCP/IP is enabled here, or disabled

    (Yours will say Protocols for SQLExpress)

    1

     

  • this is what i have...

    tcpip protocol

  • OK, and in TCP/IP and you scroll all the way to the bottom in IPAll, what is set for TCP Dynamic Ports / TCP Port?

    Also the same for the other instance too, the IPAll port and is that TCP/IP enabled.

  • i have:

     

  • Use

    TCP:myipaddress,1433

     

    then as the connection string.

    If that dont work then you'll need to work with you network admins to find out what NSG's are stopping the traffic.

    Also as I say, don't expose SQL to the internet, find yourself a better way to access SQL via a VPN to the cloud rather than over a public IP.

  • ok so like this:

     

    would using sql on azure be more secure?

     

     

  • No just put 1433 there.

    Make sure 1433 is also not in the same place in the MSSQLSERVER2012 settings too.

    Then in visual studio/SSMS whatever you use to connect put

    TCP:myip,1433

    1

  • SQL on Azure could be more secure depends again how its all setup, if you're just going to again put it on a public IP address then it wont be as secure.

    You'll need someone who knows what they are doing.

  • Do you have an outbound firewall from where you are connecting? That has been the single most frequent reason for errors like this in my experience. The folks configuring the outbound connections often block port 1433 as it's considered a risk.

  • i dont think so. should i create an outbound rule on server firewall too?

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply