Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple Multi-Tier example in C#?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Database:
Jet/Access Engine
Divers
Thread ID:
01074638
Message ID:
01074678
Vues:
17
>Does anyone have a very simple multi-tier example using an ACCESS database?<

What exactly are you looking for Cecil? Just how to structure a multi-tier app? Here's a little blurb I had written up a while ago that explains a little about this:

To simplify, think of three different projects/dlls in your solution. MyUI, MyBiz, and MyDataAccess (I'd actually throw in a 4th one, MyWebService, but let's not complicate matters at this point. Oh wait, I'd have a separate DataSet project too, but as I said, let's keep it simple for now). In your MyUI project, you'd have all the different forms that you plan to use in your UI. The same for MyBiz and MyDataAccess projects, all the different Biz classes and DataAccess classes.

So, to start, your form would be similar to this (to get your data when the form first opens):
using MyCompany.Business.MyBiz;

namespace MyCompany.WinUI.MyUI
{
  public class MyForm : MyBaseForm
  {
    private long          CustomerKey;
    private MyDataSet     dsData;
    private MyBizCustomer oBiz;
    
    public MyForm(long key)
    {
      this.CustomerKey = key;
      InitializeComponent();
      this.FillData();
    }

    public void FillData()
    {
      // To simplify, I'm directly calling a Biz class.
      // In reality, I use a Web Service here instead
      // which in turn calls the Biz class.

      oBiz = new MyBizCustomer();
      dsData = oBiz.GetCustomer(this.CustomerKey);
    }
  }
}
Now in your MyBiz project, you'd have a Biz class:
using MyCompany.DataAccess.MyDataAccess

namespace MyCompany.Business.MyBiz
{
  public class MyBizCustomer
  {
    private MyDataSet dsData;

    public MyDataSet GetCustomer(long CustomerKey)
    {
      MyDataAccessCustomer oDA = new MyDataAccessCustomer();
      this.dsData = oDA.GetCustomer(CustomerKey);

      // if you have other Biz things to do to this customer
      // do it here before returning the DataSet

      return this.dsData;
    }
  }
}
And, lastly, in your MyDataAccess project, you'd have this class:
namespace MyCompany.DataAccess.MyDataAccess
{
  public class MyDataAccessCustomer
  {
    public MyDataSet GetCustomer(long CustomerKey)
    {
      // Here's where you'd put all the SqlCommand and DataAdapter stuff
      // and fill your DataSet.

      return dsData;
    }
  }
}
~~Bonnir
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform