Accessing a remote database -- best practices

c#, database

Solution

A web service is a good way to decouple the client and server portions of your app, provide enhanced security for accessing the database, etc.

You're using MySQL on a Linux server, so if you wanted to use .NET for your server's web service as well, you'll need to use Mono http://www.mono-project.com/. Also, take a look at WCF, as this provides a lot of the web service functionality you'll need to build on. If I remember correctly, there's even a way to automatically generate an entire web service from your existing ADO.NET data layer.

If however you're comfortable using a different framework / language on the server side, there are plenty of options out there if you don't want to roll your own. Search for "restful mysql" and you'll get some leads, e.g.:

Exposing MySQL database/table using REST

http://phprestsql.sourceforge.net/

http://restsql.org

Security is going to be very important here of course. HTTPS will encrypt your communications, but you'll also need to implement solid authentication.

Problem

I want to create a C# .NET WPF application which communicates with my external Linux server. On my server runs a MySQL database. What is the best way to access the database (select, DML) without accessing it directly via ADO.NET? I have thought of a webservice, but I don't know how to create and access a webservice with C# on a linux server. Also I need a secure connection (https). I hope you can tell me best practices.

Original source