Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Moving c# programs and SQL to a new server

Posted on 2016-08-31
12
102 Views
Last Modified: 2016-09-06
We are moving our current programs to a new server.  I need to test them before they go live.  This particular program is web based using c#. When I use Visual Studio and step through my code everything works like it should.  When I publish the program and run it I get the following 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...

I am thinking it is a permissions problem but I am not familiar enough to know where to start.  Can someone help me with this?

BTW- I looked at the 'Connections' for this sql server and the 'Allow remote connections to this server' is checked.
0
Comment
Question by:huerita37
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41779011
Can you access the SQL server remotely via ssms?
0
 
LVL 1

Accepted Solution

by:
Danlo earned 250 total points
ID: 41779016
There are two places you need to set permissions in SQL Server (Management Studio).

First, you need to be sure there is a Login [Server -> Security -> Login] that matches the login the C# applications are trying to connect with.

Second, you need to add a 'User' to the database that the application connects to, using the login account you created above.

[Server -> Database -> Security -> Users]

Make sure the User has at least dbDataReader rights (for Read-only access), and also dbDataWriter rights, for the ability to modify data in the database.

HTH,
Danlo
0
 
LVL 1

Expert Comment

by:Danlo
ID: 41779020
In addition, make sure that the SQL Server instance is set to allow both SQL Server authentication and Windows Authentication, unless the C# app is impersonating a user.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41779100
Did you update the connection string to point to the new server?
0
 
LVL 13

Assisted Solution

by:Nakul Vachhrajani
Nakul Vachhrajani earned 250 total points
ID: 41779266
Going to basics - The first task is that your request must "reach" the server.

If you use SSMS on your workstation (not where the SQL Server service is hosted), can you connect to your SQL Server instance? If this is a new server that IT built, do ask IT to check the firewall. Newer operating systems block traffic and hence it is possible that you are unable to reach the SQL Server itself.

Next, check if accces to the server using TCP/IP is enabled (it is disabled by default). You can check this in the SQL Server Configuration Manager on the server (which is the same place you would go to in order to manage your SQL Server service).

If the above two points check out, then the instance level configurations of allowing remote connections and setting permissions come into play.
0
 

Author Comment

by:huerita37
ID: 41781779
I'm testing the above responses.  I am not at work on Thursdays so I am looking at it now.
0
 

Author Comment

by:huerita37
ID: 41782022
Here is my testing so far:

I am able to access the DB even if I am not on the server itself.  If I run my program locally I can access data on the SQL Server.

There is a login and user that matches what I use to connect to the SQL Server.

I am pointing to the new SQL server because I can select/update to the new server when I am testing locally.
0
 

Author Comment

by:huerita37
ID: 41782108
Is there a permission on the webserver that I need to set?  When I run the program from the new webserver but point to the old SQL server I get the same error.
0
 
LVL 13

Expert Comment

by:Nakul Vachhrajani
ID: 41782159
I believe it is the firewall on the webserver which may be blocking outbound traffic.
1
 
LVL 1

Expert Comment

by:Danlo
ID: 41782280
I believe it is the firewall on the webserver which may be blocking outbound traffic.

Nakul Vachhrajani may be correct. here.  Standard SQL Server traffic port is 1433.

From a command line window on your web server, run 'netstat -aon | more' so check if that port is being listened to/for.

If the server is not indicating that it is listening for that port, you may need to enable the TCP/IP protocols inside SQL Server Configuration Manager.

If it IS listening for that port already, it's most likely being blocked by a firewall setting.  Make sure you have SQL port open in Windows Firewall for Domain and/or Private networks.
0
 

Author Comment

by:huerita37
ID: 41786649
I have not been given permissions to get to this server.  I can only access the DB tables.  I have talked to our DB admin about everything that has been said here.  He checked the connection and it was not set to a local connection.

Thank you everyone for all of your help.
0
 

Author Closing Comment

by:huerita37
ID: 41786653
I appreciate all of your help.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question