Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I one tow have server, in another town have another pc and need to connect to same server remotly.

Need some examples

MS SQL SERVER 2016

C# Desktop app

Thank you

What I have tried:

MS SQL SERVER 2016

C# Desktop app
Posted
Updated 17-Jan-20 1:04am
Comments
[no name] 17-Jan-20 3:58am    
I would establish a VPN. This Like it is easy and more secure.

That's not necessarily as simple as it sounds: it's going to depend a lot on how the remote server is connected to the internet.

If it's a standard domestic line, forget it.
That's because "normal connections" are via Dynamic IP addresses which means each time the router is cycled a new IP address is assigned by the ISP. Because it changes, you can't use an IP address directly to connect, and you can't support a domain name on that PC because the DNS expects a Static IP and won't direct traffic correctly with Dynamic.

You can get Static IP addresses, but they generally cost extra and have to be agreed in advance.

Then there is the router, which probably has to be configured to support the incoming requests by unblocking ports, the OS and it's firewall which also has to allow them, and the SQL Server installation which has to be configured to allow remote access. Then there is the security concerns, which are a whole new bag of rats!
Once that lot is sorted, it's simply a case of using the domain or IP address as part of your connection string, and it'll all work like magic. But getting to that point requires a lot of thinking and planning, or it'll all fall over very, very quickly.

Instead, consider either using a hosting service (some do allow remote access to DB's, but these are generally ones you have to pay annually for) or a cloud solution (which again, you will have to pay for).
 
Share this answer
 
It really is not a matter a "Programming", it is a matter of "Configuration".

If the server is visible to the internet; it is simply a matter of having the servers URL or IP address and then setting your connection string to it. This is the method that is used by many web hosting companies. Your connection strings would look something like this
XML
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="DB-1" connectionString="Data Source=MSSQL.MyDomain.com; Initial Catalog=DB1; User ID=DB1_User; Password=DB1_Password; " />
    <add name="DB-2" connectionString="Data Source=127.0.0.1:1433; Initial Catalog=DB2; User ID=DB2_User; Password=DB2_Password; " />
  </connectionStrings>
</configuration
If your server is not visible to the internet, you have two options; either you configure the instance of SQL Server to be visible on the internet or you would need to set up a VPN. Neither of these are a simple answer suitable for this forum, but there is plenty of documentation depending on which way you choose to go.

Configure SQL Server for remote connections is pretty straight forward:
https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20Docs-v1.1.2/GUID-CF5C89EA-0918-4002-8391-80CBEDE0BB5E[^]

Configuring a VPN is going to depend on which VPN service you go with
The Verge : How to set up a VPN[^]
 
Share this answer
 

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