Greetings All,
This inquiry is regarding the separation of data access from a windows forms application. I currently have a class called Data which exposes static methods that basically take in the form variables and then creates, updates and deletes those variables from a sql database.
So in my form class I can call this:
Int Success = Data.UpdateDate(DateTime date); (return -1 if unsuccessful)
My question is – is there a better way to separate the data from the form logic. What are some more popular methods used
I often hear the phrase n – tier application - where you would separate out GUI, business logic and database access. Can someone explain to me how I could write an application that adheres to this methodology in C#
A side note, this forum has been incredibly useful, so thanks to all.

Separating data access form code.
Dmitriy Velichkin
Your data class should contain methods that perform specific database actions, such as storing a record, or retrieving a record set. The idea is that it defines the sort of actions that need to happen on a datastore, while hiding all details of the nature of the data store. You should be able to change your database, or move to some other format, such as XML files, simply by changing the internals of this class.
Anything that is not related to your UI directly ( that is, the drawing of the UI and responding to user actions ) and does not call your database, is your middle tier. Your presentation tier should do as little as possible.
brewdos
Good insight.
Ok, so right now I kind of have two tiers going. The dataclass I have talks directly to the database. As you can see, I pass the form variables to the dataclass and have the dataclass talk to the database.
In my scenario, how can I take advantage of the business tier
Let me know if I need to clear anything up.
SteveK1111
>>I often hear the phrase n – tier application - where you would separate out GUI, business logic and database access. Can someone explain to me how I could write an application that adheres to this methodology in C#
Generally, what I do is build a dll that contains my business logic. I build another dll which contains my code that calls stored procs in the database. The presentation tier generally takes care of the way the UI looks and behaves, and it gets the information to display from the middle tier, which is responsible for implimenting my business rules, and generally is responsible for passing data to and from the database ( although sometimes the presentation tier will call the data tier directly ).
If it's not got to do with the way your interface looks, then it probably does not belong in the presentation tier. The idea is that if someone wrote a whole new UI, they could use your two dlls to write a nre program that does exactly what the old one did, all the logic is in those dlls.
vladgrig
Nicola Tuveri