hridya
hridya

Reputation: 183

.net Desktop application deployment and database connection

Actually i m confused and really need advice. In past i developed various web applications , where i give connection string in web.config and then deploy database and web files on a hosting company site. Now i started window desktop app development but i dont know how to connect a desktop application with a database on a server , because hosting company do not allow to access database remotely . so i tried google searching and there i got to know that we can use wcf , but i really need advice what should be the best way to start and also if wcf is the way how can i do this.. For an e.g. we can take scenario where i need to save employee name to the database lying on server from desktop app. , and yes one more question ! the deployment of database on the server for web app and desktop app is same or not ? if not then how can i deploy my desktop app database

Upvotes: 1

Views: 3005

Answers (4)

SteveChapman
SteveChapman

Reputation: 3081

I know this question is answered, but I think it's very relevant to express just how important it is to get your framework selection right before you go down the coding route, especially if you're providing a product to external clients. You should definitely think twice about committing to closed frameworks for your web service development (such as WCF). In the event that you hit any framework issues during development or future support of your product, you're immediately bound to constraints that can severely hamper your ability to develop and maintain the product. Much better to have a direct line of access to the actual code, and more importantly to the ability to submit changes to fix issues.

Definitely take a look at ServiceStack or NancyFX as frameworks that trivialise the implementation of web services.

Take a look before going the WCF / WebAPI route - you won't regret it.

Upvotes: 1

juhan_h
juhan_h

Reputation: 4011

I would go with WCF as well. Although it is true that the barrier to entry is much lower in Web APIs WCF provides much more flexibility.

WCF gives you the freedom to choose your transport:

  • If you do not need any other application to access your service you can use TCP connections with binary formatting which could be custom
  • If you need other applicattions to access you could provide SOAP/JSON based HTTP connections to those (but could still keep the fast TCP stuff for your app)

WCF gives you the flexibility to decide how to manage authorization:

  • You could use certificates for authentication and encryption to make the process fairly secure and invisible for the endusers.
  • You could use basic HTTP authentication with users/passwords in configuration files.
  • You could allow anonymous access

It takes some time to get your head around WCF but after you have figured it out it is a very powerful tool.

Upvotes: 1

Ehsan
Ehsan

Reputation: 32681

i dont know how to connect a desktop application with a database on a server

You need to implement SOA architecture.

but i really need advice what should be the best way to start and also if wcf is the way how can i do this

Well, WCF isn't the only way to do it. You can do it will asmx webservices as well. But WCF is the best way to do it (in my opinion). You may find it hard to get a grip on it initially, but once you do, you will say that it is worth it.

For an e.g. we can take scenario where i need to save employee name to the database lying on server from desktop app

Sample call for saving: Desktop --> BusinessRule-->Service Call --> Data Access --> Save in db

this is the simplest and the most straigh forward way of doing it.

the deployment of database on the server for web app and desktop app is same or not

It is the same.

Upvotes: 2

Roy Dictus
Roy Dictus

Reputation: 33139

In my opinion, the best way would indeed be to write a WCF service and have that service access the database.

So your desktop application connects over the Internet to your WCF service; that WCF service exposes business logic (implemented in business classes; if you want to follow best practices) which accesses the database. Your desktop application has no idea that there even is a database, and so it has no connection string to deal with, etc. It just connects to the WCF service which hides the complexities of the database etc.

Get someone to help or coach you because WCF can be a bit daunting at first. MSDN has a good tutorial to start with: http://msdn.microsoft.com/en-us/library/ee354180.aspx.

Don't make your first implementation very complicated. Just use .NET 4 or 4.5 so that you don't need a lot of WCF configuration (in .NET 3.5 you need a lot of XML or code to configure WCF properly; from 4.0 this is a lot easier to do).

Good luck!

Upvotes: 2

Related Questions