Solved

Moving c# programs and SQL to a new server

Posted on 2016-08-31
12
98 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 62

Expert Comment

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

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 12

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS with VPN COnnection 2 70
VB.Net Tranfer data between to VB.Net apps 8 25
C# Gridview 1 29
Query to capture 5 and 9 digit zip code? 4 20
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
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.

786 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