Search code examples
c#asp.netsql-serversql-server-2014sqlconnection

Can't open the connection after upgrading to SQL Server 2014


Recently I have upgraded my SQL Server from 2012 to SQL Server 2014.

Now all my applications connected to this server can't instantiate the connection.

I debug the code and I get the following exception :

'Connection.ServerVersion' threw an exception of type System.InvalidOperationException

My connection string like this :

 <add name="sql_r" 
      connectionString="Data Source=172.XX.XX.X;Initial Catalog=Attendance;User ID=ll_web;password=XXXXXXXXXXX;" 
      providerName="System.Data.SqlClient"/>

Solution

  • Apart from the code, there are a couple of possible things which could make your SQL Server Connection failed from the setup itself. I will try to list 3 which I think might be common:

    1. Check your SQL service, whether it is running. Check your service by running "service.msc" from your Run windows. Check for service name SQL Server (YourInstanceName) (the default for YourInstanceName is MSSQLSERVER). Check if it is running. You may also want to check if SQL Server Browser is running. Run them.
    2. Check you Firewall, check if your newly installed SQL Server paths are among the allowed paths. You could get the paths by [right-clicking - properties -> path to executable] on the service names of your SQL Server in point 1. Include them in your Firewall allowed paths.
    3. Check your TCP Port, Open the SQL Server 2014 Configuration Manager, in the SQL Server Network Connection -> Protocols for [YourInstanceName] -> TCP/IP. Do right-click -> properties -> IP Addresses Tab, check the TCP Port for you IP Addresses. Typically all is set to 1433, including the IPAll. If this is not the case, set them.