0

I was wondering why I can't connect my application (C# Form from another pc) to my SQL Server?

I have followed these links, and use Virtual Box as my VM.

https://www.youtube.com/watch?v=aIovZluNmNs

How to connect to SQL Server from a C# program on another computer

Connecting to SQL server from another computer

  • Enable TCP/IP from the Configuration Manager
  • Use TCP Port 1433 (IPALL)
  • Restart SQL Server from the Configuration Manager
  • Added TCP Port from the Firewall (also UDP Port 1434, and SQLServer.exe), both server and VM
  • From my VM, I can ping my server ip (192.168.1.10)

But I still get this 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. (provider: TCP Provider, error: 0 - No such host is known.)

Connection strings that I have tried are:

Data Source=ip_address,1433; Initial Catalog=inventory; Integrated Security=True
Data Source=server_name,1433; Initial Catalog=inventory; Integrated Security=True
Data Source=ip_address,1433; Initial Catalog=inventory; Integrated Security=False
Data Source=server_name,1433; Initial Catalog=inventory; Integrated Security=False
4
  • You need to add username and password to the connection string for a user that can access the sql Commented Apr 7, 2018 at 10:25
  • Are both computers on the same Domain? That is - is there a domain controller on the network? If not, you need to refer to the comment by @3dd Commented Apr 7, 2018 at 10:28
  • I dont have or I'm not using any user/pass. Commented Apr 7, 2018 at 10:28
  • @Jepher you can use Integrated Security=True if you are calling database from another computer, you will have to do SQL Authentication instead of windows. Commented Apr 7, 2018 at 10:30

1 Answer 1

0

First add a new user to login your credentials. Your connection string should be look like this Data Source=(server);Initial Catalog=(server);User ID=(username);Password=(password)

Next open your Windows Firewall with advanced security on your server.

  1. Add new rule.
  2. Select TCP and set on specific local port 1433.
  3. Allow the connection.

and restart your server and try to connect again.

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

3 Comments

i have created a new login credentials. but im encountering this error "The database inventory is not accessible. (ObjectExplorer)". resolve the issue by setting the created user to be sysadmin.
but i have found out also in this link a solution "msdn.microsoft.com/en-us/library/ms188236(v=sql.110).aspx" but im lost on the procedures. i dont know how can i get to SQL Server advanced Properties, and where is the command prompt in the sql server?
On your Login Property>User Mapping select your database and set role membership to owner.

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.