tags:

views:

34

answers:

2

I've got a webserver running quite standard Apache/php/MySQL and want to connect to this MySQL database from a desktop application written in c#/wpf.

First, how can I connect? Do I need some special SQLConnection library?

Second, how safe is this? Anything special I need think about for security since the database is in the web and not local?

A: 

You could connect to MySQL if you allow connections (to MySQL) from the IP addresses the desktop (WPF) clients are running from. Just create users and allow them to connect directly to the database. It's not unsafe. But your MySQL repository could become harder to maintain (you will have lots of users, logging from different subnets, etc.).

I would recommend to create a WEBSERVICE or RESTFUL API in your Apache/PHP/MySQL Server, and connect to that service with C#.

Pablo Santa Cruz
+1  A: 

Anything special I need think about for security since the database is in the web and not local?

Well, I would say, that one should not expose the database directly to the web, under almost any circumstances. Mostly for security reasons, too.

Maybe you should write a web API (REST/RPC/whatever) to your data and access it over HTTP instead? This way you don't need to expose the actual database to the whole internet AND you have a chance of being database-schema-agnostic (you desktop app doesn't need to care about the structure of your database, but only about the interface your web service provides).

shylent
Actually I use a standard virtual server and have no say if it is to be exposed to the internet or not. I just want to connect to an existing database using a native program for easier maintainence.
Sam
@Sam well, is it? I mean, is it exposed? My bet is that it is listening on the loopback only so that only the web stack on the same host can connect to it. I wouldn't imagine, that the db server would be accessible from the outside world in a default configuration.
shylent
I just checked: it is accessible. It's a standard webhosting contract (virtual shared server), nothing fancy.
Sam