Connect server DB to desktop application in C #

2

I just finished my application which I developed in C # using windows forms, it is a desktop application, which works with a local database.

The application will be installed in clothing stores outside the company. My question is: How can I connect the application to the database of the server that is held in the company ?. Since what I intend is that the records that are made inside the application can be reflected and stored in the database of the server. Remembering that until now I only have it locally.

How would my connection string for the server database be? o What other solution do you recommend for this case?

Thank you I hope to have explained. Greetings

    
asked by Ezequie Lopez 30.08.2018 в 01:53
source

1 answer

6

The first thing would be to have the server published on the web, with a public ip that points to the server that you have in the company.

After that, the connection string would not change much from the one you already have, only in the name of the server would you put the public ip.

If you use a configuration file it would look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <connectionStrings>
    <add name="cnxString" connectionString="Data Source=190.148.47.24<!-- Esta es la ip publica-->;Initial Catalog=MiBaseDeDatos;Integrated Security=False;User Id=USUARIO;Password=CLAVE" providerName="System.Data.SqlClient"/>    
  </connectionStrings>
</configuration>

As you can see, the key is to configure external access to your server, it could be through the router or the device with which the network traffic in your company is controlled.

The other option is to migrate your database to the cloud, you could use the services of Azure or Amazon WebServices.

If you want to know how to configure external access, you can review this question Is it possible to connect to SQL Server Standard from a desktop application of a machine outside the network?

    
answered by 30.08.2018 / 02:30
source