0

I wanted to create a desktop application with C# and also create a website with PHP. Both will use same DB. You'll create an account from website and login from app. Take notes with app, send to db etc. etc.

But my (a lot of stars) hosting company does not allow me to use remote mysql. They said "add IP address from cPanel". Give me all of the worlds IP address so I can add. Meh..

So in this scenario, what can I replace with mysql? Summary: I need to create a C# application and a website. Both will use a remote DB. What can I do?

Diga
  • 481
  • 2
  • 9
  • 20
  • In your scenario it is common practice to create a webservice which will be used both by the website and the desktop application. In doing so, you will only need to implement database access once instead of duplicating CRUD methods in PHP **and** C#. – Filburt Feb 19 '15 at 23:20
  • I honestly have no idea how to do your method. But still, thanks for your answer. I can't take this way. Can I use access db from remote server? – Diga Feb 19 '15 at 23:37
  • Maybe [How to write a REST API](http://stackoverflow.com/questions/4973156/how-to-write-a-rest-api) gives you an idea (swap phone app with desktop app). Basically this kind of interface is the only way to go in a hosted environment. Direct access to your database will open your data to hacker attacks. – Filburt Feb 20 '15 at 00:35
  • A little search did turn out this [List of tutorials on how to create an API](http://blog.mashape.com/list-of-40-tutorials-on-how-to-create-an-api/). – Filburt Feb 20 '15 at 00:38

3 Answers3

0

Hosting companies really don't like to make their MySQL servers accessible from the whole internet. You share that server with other customers, and it's pretty easy for cybercriminals to crack, or to do a denial-of-service attack, on MySQL if they can get to it. Considered harmful.

Some hosting companies, including yours, make an exception so you can whitelist one or a few particular IP addresses for remote connection to MySQL via the net. Apparently that solution is not workable for you.

But, they would be insane to allow access from the whole internet. If you owned the MySQL server (or the Oracle, postgreSQL, MS SQL Server or DB2 server) you too would be insane to allow access from the whole internet.

Desktop applications which access remote databases over the public internet are vanishingly rare, for precisely this reason of security. That sort of approach to application development is much more commonly deployed inside corporate firewalls.

It looks like development of a webservice is in your future if you must deploy a desktop app. The good news is there are many good and secure ways to do that.

Dotnet provides a good, if complex, infrastructure for webservice development in their WCF (Windows Communication Foundation) subsystem. A webservice is basically a web site that's designed to be accessed by programs rather than by humans via browsers. The two generic terms for webservice architectures are REST and SOAP.

Desktop programs (like online games) that use network resources usually are set up as clients of one or more webservices.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • what kind of approach does online games use? you register from their site and then use a desktop application to play. – Diga Feb 20 '15 at 00:21
0

You can do it. You need to allow remote mysql connection , i'm taking about hostgator. But its my suggestion do not directly connect with database. Its better make a restful apps & exchange data in between server.

jewelhuq
  • 1,210
  • 15
  • 19
0

You can do it in the following way 1.First login to your hostgator cpanel then enable remote connection adding % symbol 2.Now you can easily connect database as follow If you use pocoorm

<?xml version=”1.0″?>
<configuration>
<connectionStrings>
<add name=”mysql” connectionString=”server=**yourdomain.com;database=test;user id=database_url;password=databse_password;**” providerName=”MySql.Data.MySqlClient”/>
</connectionStrings>

<startup>
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″/>
</startup>
</configuration>

But you know C# is breakable , i mean your code can be decoded anytime. So it would be best to connect your database with restful api.

jewelhuq
  • 1,210
  • 15
  • 19