hi,

What is 3-Tier Architecture and how is it implemented in ASP.NET?

Can anybody please make me clear regarding this doubt..?

Recommended Answers

All 3 Replies

Three Tier approach is basically your UI,Business Logic layer,Data Access layer.

Your UI is imply your HTML elements. You should have no data access logic such as SQL code at all.
You communicate with your Data Access Layer through your Business Logic Layer. In your BAL you define Properties and Methods for communicating with your DAL which in turn communicates with your DB. Basically the concept is isolating your code so changes in one will have no impact in another. Which, as you can see can make managing your application a bit easier.
Go here http://www.asp.net/web-forms/data/
You will find excellent examples, step by step guide.

regards,
dsweb1017

hi,

What is 3-Tier Architecture and how is it implemented in ASP.NET?

Can anybody please make me clear regarding this doubt..?

I recently implemented a 3-Tier architecture in Visual Studio 2008. My Data Access Layer contained TableAdapter classes with methods to populate datatables and propagate the changes back to the database. The TableAdapter is nice because you don't have to write any data access code or include any connection string information.

The Presentation Layer should be used to allow users to interact with the application. For the most part, this layer will contain your UI components(.aspx pages). From either your Presentation Layer or your Business Logic Layer you can create an instance of the TableAdapter and then access its methods with Intellisense.

public class ProductsBLL
{
private ProductsTableAdapter _productsAdapter = null;
protected ProductsTableAdapter Adapter
{
get
{
if (_productsAdapter == null)
_productsAdapter = new ProductsTableAdapter();
return _productsAdapter;
}
}
[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, true)]
public ASPDevComp.App_Code.DAL.AdventureWorks.ProductsDataTable GetProducts()
{
return Adapter.GetProducts();
}
}

Your Business Logic Layer should encapsulate your application logic. Any business rules or calculations and validation related to the data should be handled in this layer.

if (products.Count == 0)
{
return false;
}




if (MakeFlag)
{

throw new ApplicationException("You cannot edit the color of a product if MakeFlag is true.");

}

int rowsAffected = Adapter.Update(product);
return rowsAffected == 1;

This is a helpful link http://www.asp.net/learn/data-access/tutorial-02-cs.aspx

The code provided bsiemssen will work well for you. He is using a Dataset Type Object to perform BLL and DAL.
The PDF and video provided in the link are very good and you should take time to look over.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.