Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.40/5 (2 votes)
See more: , +
I Want to connect to SQL server from a windows application, that can be install on any PC but database should be same on my own server.

What I have tried:

I have searched a lot but can't get any solution, I just found how to connect on same network.But i want to connect from cross network.
Posted
Updated 5-Jan-17 20:38pm
Comments
F-ES Sitecore 6-Jan-17 4:50am    
Just to expand on solution 1, for the client to see your database then the two obviously have to be on an accessible network otherwise it's like trying to phone someone when you don't know their phone number, or trying to speak to someone who is in a different building. If this is not a corporate environment then you might well need to use the internet as the network both machines are on, so either give your server a fixed IP that is exposed on the internet, or register a domain for it "sql.mydomain.com" or whatever, and that is what you use in the connection string;

server=sql.mydomain.com;

You'll obviously need to consider the security aspects of all of this though.

1 solution

If I understand your question correctly, in order to connect from remote PC to the SQL Server you need to know the IP address where the server resides and the port the SQL Server is using. For the syntax of the connection string using IP address, have a look at Connect via an IP address - SqlConnection - ConnectionStrings.com[^]

Ensure that communication between the computers is allowed using that port so that for example firewalls do not block it. Another thing is that if you're using public networks, the traffic can be seen and the the SQL Server is available in public so I suggest for example using VPN in such case and blocking all access to SQL Server from outside world.
 
Share this answer
 
Comments
Member 12882662 6-Jan-17 3:20am    
If we have setup all good.can I connect it from any PC worldWide??
if yes! then how??
Wendelius 6-Jan-17 3:29am    
I'm sorry but I don't understand your concern. As said you need to
- have technical, secure connection between the computers (tcp/ip)
- you define the IP address and the port in the connection string
- you connect
Member 12882662 6-Jan-17 4:49am    
Thanks for reply..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900