views:

16

answers:

2

VS2010: What is the best way to access a remote database over the internet from a WinForms application? By that I don't mean talking to the database (SQL Server) directly, but rather through a service. Best if I could use http as a protocol to avoid firewall issues.

+1  A: 

Would recommend that you look at WCF

If you have control over both ends of the connection, you then can change protocol etc through configuration, but yes, http:80 is usually the easiest way to adhere to firewall policies.

nonnb
A: 

If you wish to keep this simple and your needs are limited you could always use a typed dataset that you pass over WCF (or .Net Remoting). However you will quickly hit problems if your app gets more complex or you have lots of data.

SqlServer will exposed stored procs over soap, this may work well if your applications uses a few stored procs that are not too chatty.

Exposing your data with WCF Data Services is an option if you want simple CRAD operations. Otherwise you will have to define all the methods you need on WCF interfaces.

If you are not tied to WinForm, look at WCF RIA Services with Silverlight as this will do a lot of the hard work for you with most CRAD type applications. But you will need to learn Silverlight.

The problem is there is no simple and easy solution to “presenting the internet is not in the way” and moving to a 3 tier application will always make your code more complex. A 3 tier architecture can be great for more complex and demanding applications, but is often over kill.

Also consider writing a 2 tier WinForms application and using Terminal Services to expose it to your clients over the internet. This is often the cheapest solution and tends to give the least pain with system admin. However a lot of programmers think it is “cheating” for some reason.

Ian Ringrose