ASP.Net/C# – Creating Business Logic Layer / Data Access Layer

Posted by nsrajesh On February - 12 - 2010

Download this Tutorial Project

Please make comment is you think this articles helps you.

How to create/use Business Logic Layer / Data Access Layer in ASP.Net project

Do you guys know how to create a Simple ASP.Net project with Business Logic Layer (BLL) & Data Access Layer (DAL) along with Presentation Layer or User Interface Layer (UI) – Simply ASP.Net Project…

Lets learn together.

First step is to Create an ASP.Net project (hope you guys know how to create ASP.Net Project :) ) – Lets name it as “SampleProject”.  While saving the project Save it in your wwwroot Folder. Mostly it will be in C:\Inetpub\wwwroot\.

Now you solution explorer will look like this.

DAL-BAL-Solution-Explorer

DAL-BAL-Solution-Explorer

Creating BLL

Our next step is to create the Business Logic Layer (BLL) & Data Access Layer (DAL) – From now on we will call it as BLL / DAL. For BLL & DAL layer we need to create DLL Files – using Class Library Projects. So just right click on your Project’s Solution file as show below.

Selecting Solution to add BLL & DAL

Selecting Solution to add BLL & DAL

Now select Windows in Project Type – left hand side of the dialog box. Then select Class Library in Templates – right hand side. Now give the project name as “SampleProject.BusinessLogic” – Save this project in wwwroot folder itself.

Now your project explorer will look like below.

solution-exporer-bal-asp

Creating DAL

Follow the same steps that you used to create the BLL  to create the DAL project and name the project as “SampleProject.DataAccess“.

This is how your solution explorer will look like now.

Solution Exporer with UI Layer, BLL, DAL

Using all three Layers

Now we have UI, BLL & DAL projects is in place. So how we are going to interact all these projects. Now we are going to create a login page where users can login.

And we are not going to use any ASP.Net controls like Login / Login View / Login Status etc… to create this login page. Also we are going to use Microsoft Enterprise Library to access the Database. If you don’t know Enterprise Library, please don’t worry – Its just like OLEDB.

Now, while the user logs in into our product our all projects (UI, BLL & DAL) will interact like below.

1. UI Layer – User will enter the User Name / Password to enter into our project.

2. BLL – We will check whether he entered both the User Name & password – if not we will show them an error like “Please enter the User Name” or “Please enter the Password”.

3. DAL – If the user entered both the “User name & Password” then will check that User Name & Password in the database – whether its correct or not.

This is how all three projects will interact with each other.

Please read the Part 2 of this tutorial

If you still have issues please let me know through comment. I will try to help you – even on skype chat.

One Response to “ASP.Net/C# – Creating Business Logic Layer / Data Access Layer”

  1. Good… still we are expecting more boss…

Leave a Reply

VIDEO

Enter the video embed code here. Remember to change the size to 320 x 270 in the embed code.

TAG CLOUD

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Sponsors

About Me

Hi all, my name is Rajesh & i am a full time developer who loves to work on Challenging Projects. I am specialized in ASP.Net, C#, PHP, MySQL & MS SQL. This Blog\'s goal is to provide tips/help to others. I will try to post most useful Articles once in a while.

Twitter

    Photos

    Activate the Flickrss plugin to see the image thumbnails!