2

I need to access database in another computer using c#...I am using connection string with IP address for accessing database and also changed firewall setting but it shows error as follows

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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

I m using this connection string

SqlConnection con = new SqlConnection("data source=192.168.1.12,1063;initial catalog=trinity;integrated security=false;network library=DBMSSOCN");
4
  • How did you configure the firewall? Commented Jan 28, 2015 at 11:43
  • Did you change the default port from 1433 to 1063? Did you enable the TCP protocol on the Sql Server Configuration manager? Commented Jan 28, 2015 at 11:43
  • Have you checked the Native Client Configuration for TCP/IP enabled from MSSQL Server Configuration Manager? Commented Jan 28, 2015 at 13:17
  • i enabled TCP/IP in sql server configuration manager and also create new rule in firewall...setting port UDP as 1434 and TCP as 1433 Commented Jan 29, 2015 at 5:50

2 Answers 2

1

This is actually quite a large topic involving: Networking, Authentication, Authorization and Permissions. Quick checklist:

  1. Open port 1433 on local firewall where SQL Server is running.
  2. Open SQL Server Configuration Manager on the local machine where SQL Server is running and enable TCP connections.
  3. Add a Windows Login or SQL Account user and grant permissions to the database. DON'T USE THE SA ACCOUNT TO CONNECT REMOTELY EVER!.

In your connection string you have Integrated security=false;, so you need to provide User ID=mysqlserveruserid;Password=mysqlserverpassword; parameters in your connection string instead. If you change Integrated security=true; your Windows credentials will be used.

Also why the IP Address? Do you not have network name resolution on your network? e.g. DNS or WINS.

Is SQL Server running as the default instance or does it have a named instance? If it's a named instance (would have been a choice taken when installing SQL Server) You will need Data source=computername\sqlserverinstancename;

More detailed information on all these aspects can be found on MSDN https://msdn.microsoft.com/en-us/library/ms345332.aspx

Sign up to request clarification or add additional context in comments.

Comments

0

Try given solutions, it may help you

http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx

3 Comments

why not ? if it is Microsoft community and can help you, which another user needs time to type explanation here , isn't it a good answer? user can more goggle next time for such questions...
@Disha links are prone to becoming dead ends (404's) in the future. It is better to add as much of the pertinent info as you can into your answer from the resource you are linking too as well as posting the link. But, it's up to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.