views:

140

answers:

4

This may appear a newbie question but forgive me I am new to the world of dot Net.

I have to make a desktop application that connects to a local SQL Server database. However in some cases the same database will be running on a server which can be accessed via the internet.

What is the best way to design such a program. Basically the program is a collection of data entry forms, I was thinking of making every query as a webservice to fetch data from the server and then post it back as a webservice. But is there a better way to tackle such a problem ? I want to use the same program in both cases, just make a change in a config file to tell the program to use local database or the database on the remote server. Since I am new I dont know how to architect the program. I've heard a bit about ADO.Net data services ? is that the best way to go around this problem and where will LLB Gen pro fit in??

Thank you for your help

A: 

You could just go the normal route of using ADO.NET connecting to the database server with a connection string through a SqlConnection object. Just make sure the "connecting over the internet" permits that kind of connection (it probably will unless you got some nasty firewall blocking it).

Per Hornshøj-Schierbeck
A: 

Hojou thanks for the quick response.Was wondering if there was any other "more optimised" way of doing it.

Rainer
+1  A: 

.NET Remoting or WCF would be more optimal. WCF would allow you to use different channels, whether it be Web Service or a binary data format. Either of the methods is configurable. The Remoting option would allow you to have the same API running locally or in a service, though the details may be tricky. In general, Web Services are better for application working via internet because the HTTP protocol can be configured or allowed to go through proxies and firewalls.

Greg Ogle
+1  A: 

I would personally build that sort of logic into your DAL (Data Access Layer). Be it using ADO.Net or otherwise, the concept remains the same in that you build a flexible way of connecting to both remote databases as well as local databases based on the fact that it's a requirement for your application.

The devil is in the details after that. You'll certainly want to have a look at links such as this one on occasionally connected applications from Microsoft.

Also check out this link on building a DAL with ADO.Net.

Best of luck!

Mat Nadrofsky