Wednesday, May 1, 2013

3 Tier Architecture in Visual Studio 2010 with sample Project

1 comment
In this article we will study how to create project in 3-tier architecture . This article is developed using visual studio 2010 but also applicable to previous version of Visual Studio as well.
Steps to create three tier architecture in asp.net using C# are as follows:

Step 1: Open Visual Studio and add new project. Under Installed Template select Other Project Types and then select Visual Studio Solutions name the solution and click on ok button as shown in the picture below:
Add New solutions in vs 2010


Step 2: Right click on solution added in step 1 and then Add-> New Project. In the new project template select Visual C# and then select Class Library . Name this Student.BAL  for example . This  would  be the Business Access Layer to get and set properties as shown in diagram below:

3 tier architecture in visual studio 2010




Step3: In this step we will add Data Access Layer  To add this layer Right Click on the Solution in Solution Explorer then select Add -> New Project.
In the Add New Project Window select Visual C# under the Installed and Select Class Library . Name it STUDENT.DAL as shown in the diagram below:
Data Access Layer in 3 tier architecture


Step 4: In the next step of creating 3 tier architecture in asp.net is to add Presentation Layer. To add presentation Layer Right Click  on Solution and then Add->New Project. Select Visual C# and Select the Option Web.Select ASP.Net Empty web Application and name it Student.Presentaion and click on Ok as show below in picture:
Presentation Layer in 3 tier architecute

Step 5: Now add the reference of project in each other. To add the reference of Business Access Layer and Data Access Layer in Student.Presentation . Right click on Student.Presentation then Add Reference . In Add Reference window select Project Tab Select STUDENT.BAL and STUDENT.DAL and click on OK button as shown in image below. Similarly in the Data Access Layer i.e. STUDENT.DAL add reference of Business Access Layer STUDENT.BAL .
Adding project reference in visual studio


Step 6: In the final step Build the solution.

Download the sample project with sql database script in 3 tier architecture with Save, Delete and Showing Data in Grid.
 Download Sample Code






1 comment:

  1. Nice tutorial...it really helped me as a newbie in implementing 3 tier architecture

    ReplyDelete