Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

3 tier architecture example in asp.net with C#

May 17, 2010
Introduction

Here I will explain about uses of 3-Tier architecture and how to create or implement 3-tier architecture for our project in asp.net 

Description

1.    What is the use of 3-tier architecture and why we go for that architecture? 
2.    First we need to know what 3-Tier architecture is. 
3.    How to create 3-Tier architecture for our project?

 Uses of 3-Tier Architecture
  
1.    To make application more understandable. 
2.    Easy to maintain, easy to modify application and we can maintain good look of architecture.

3.    If we use this 3-Tier application we can maintain our application in consistency manner.   

Basically 3-Tier architecture contains 3 layers

1.    Application Layer or Presentation Layer 
2.    Business Access Layer(BAL) or Business Logic Layer(BLL) 
3.    Data Access Layer(DAL)

Here I will explain each layer with simple example that is User Registration

Application Layer or Presentation Layer

Presentation layer contains UI part of our application i.e., our aspx pages or input is taken from the user. This layer mainly used for design purpose and get or set the data back and forth. Here I have designed my registration aspx page like this

This is Presentation Layer for our project Design your page like this and double click on button save now in code behind we need to write statements to insert data into database this entire process related to Business Logic Layer and Data Access Layer.

Now we will discuss about Business Access Layer or Business Logic Layer 

Business Access Layer (BAL) or Business Logic Layer (BLL)

This layer contains our business logic, calculations related with the data like insert data, retrieve data and validating the data. This acts as a interface between Application layer and Data Access Layer

Now I will explain this business logic layer with my sample

I have already finished form design (Application Layer) now I need to insert user details into database if user click on button save. Here user entering details regarding Username, password, Firstname, Lastname, Email, phone no, Location. I need to insert all these 7 parameters to database. Here we are placing all of our database actions into data access layer (DAL) in this case we need to pass all these 7 parameters to data access layers.
In this situation we will write one function and we will pass these 7 parameters to function like this
String Username= InserDetails (string Username, string Password, string Email, string Firstname, string Lastname, string phnno, string Location)

If we need this functionality in another button click there also we need to declare the parameters like string Username, string Password like this rite. If we place all these parameters into one place and use these parameters to pass values from application layer to data access layer by using single object to whenever we require how much coding will reduce think about it for this reason we will create entity layer or property layer this layer comes under sub of group of our Business Logic layer

Don't get confuse just follow my instructions enough
How we have to create entity layer it is very simple 

Right click on your project web application---> select add new item ----> select class file in wizard ---> give name as BEL.CS because here I am using this name click ok

 Open the BEL.CS class file declare the parameters like this in entity layer 

Don’t worry about code it’s very simple for looking it’s very big nothing is there just parameters declaration that’s all check I have declared whatever the parameters I need to pass to data access layer I have declared those parameters only 

BEL.CS


#region Variables
/// <summary>
/// User Registration Variables
/// </summary>
private string _UserName;
private string _Password;
private string _FirstName;
private string _LastName;
private string _Email;
private string _Phoneno;
private string _Location;
private string _Created_By;
#endregion

/// <summary>
/// Gets or sets the <b>_UserName</b> attribute value.
/// </summary>
/// <value>The <b>_UserName</b> attribute value.</value>
public string UserName
{
get
{
return _UserName;
}
set
{
_UserName = value;
}
}

/// <summary>
/// Gets or sets the <b>_Password</b> attribute value.
/// </summary>
/// <value>The <b>_Password</b> attribute value.</value>
public string Password
{
get
{
return _Password;
}
set
{
_Password = value;
}
}

/// <summary>
/// Gets or sets the <b>_FirstName</b> attribute value.
/// </summary>
/// <value>The <b>_FirstName</b> attribute value.</value>
public string FirstName
{
get
{
return _FirstName;
}
set
{
_FirstName = value;
}
}
/// <summary>
/// Gets or sets the <b>_LastName</b> attribute value.
/// </summary>
/// <value>The <b>_LastName</b> attribute value.</value>
public string LastName
{
get
{
return _LastName;
}
set
{
_LastName = value;
}
}

/// <summary>
/// Gets or sets the <b>_Email</b> attribute value.
/// </summary>
/// <value>The <b>_Email</b> attribute value.</value>
public string Email
{
get
{
return _Email;
}
set
{
_Email = value;
}
}

/// <summary>
/// Gets or sets the <b>_Phoneno</b> attribute value.
/// </summary>
/// <value>The <b>_Phoneno</b> attribute value.</value>
public string Phoneno
{
get
{
return _Phoneno;
}
set
{
_Phoneno = value;
}
}

/// <summary>
/// Gets or sets the <b>_Location</b> attribute value.
/// </summary>
/// <value>The <b>_Location</b> attribute value.</value>
public string Location
{
get
{
return _Location;
}
set
{
_Location = value;
}
}

/// <summary>
/// Gets or sets the <b>_Created_By</b> attribute value.
/// </summary>
/// <value>The <b>_Created_By</b> attribute value.</value>
public string Created_By
{
get
{
return _Created_By;
}
set
{
_Created_By = value;
}

Our parameters declaration is finished now I need to create Business logic layer how I have create it follow same process for add one class file now give name called BLL.CS. Here one point don’t forget this layer will act as only mediator between application layer and data access layer based on this assume what this layer contains. Now I am writing the following BLL.CS(Business Logic layer)


#region Insert UserInformationDetails
/// <summary>
/// Insert UserDetails
/// </summary>
/// <param name="objUserBEL"></param>
/// <returns></returns>
public string InsertUserDetails(BEL objUserDetails)
{
DAL objUserDAL = new DAL();
try
{
return objUserDAL.InsertUserInformation(objUserDetails);
}
catch (Exception ex)
{
throw ex;
}
finally
{
objUserDAL = null;
}
}
#endregion
Here if you observe above code you will get doubt regarding these
what is
BEL objUserDetails
DAL objUserDAL = new DAL();

and how this method comes

return objUserDAL.InsertUserInformation(objUserDetails);

Here BEL objUserDetails means we already created one class file called BEL.CS with some parameters have you got it now I am passing all these parameters to Data access Layer by simply create one object for our BEL class file 

What is about these statements I will explain about it in data access layer

DAL objUserDAL = new DAL();
return objUserDAL.InsertUserInformation(objUserDetails);

this DAL related our Data access layer. Check below information to know about that function and Data access layer

Data Access Layer(DAL)

Data Access Layer contains methods to connect with database and to perform insert,update,delete,get data from database based on our input data

I think it’s to much data now directly I will enter into DAL

Create one more class file like same as above process and give name as DAL.CS

Write the following code in DAL class file


//SQL Connection string
string ConnectionString = ConfigurationManager.AppSettings["LocalConnection"].ToString();

#region Insert User Details
/// <summary>
/// Insert Job Details
/// </summary>
/// <param name="objBELJobs"></param>
/// <returns></returns>
public string InsertUserInformation(BEL objBELUserDetails)
{
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("sp_userinformation", con);
cmd.CommandType = CommandType.StoredProcedure;
try
{
cmd.Parameters.AddWithValue("@UserName",objBELUserDetails.UserName);
cmd.Parameters.AddWithValue("@Password", objBELUserDetails.Password);
cmd.Parameters.AddWithValue("@FirstName", objBELUserDetails.FirstName);
cmd.Parameters.AddWithValue("@LastName", objBELUserDetails.LastName);
cmd.Parameters.AddWithValue("@Email", objBELUserDetails.Email);
cmd.Parameters.AddWithValue("@PhoneNo", objBELUserDetails.Phoneno);
cmd.Parameters.AddWithValue("@Location", objBELUserDetails.Location);
cmd.Parameters.AddWithValue("@Created_By", objBELUserDetails.Created_By);
cmd.Parameters.Add("@ERROR", SqlDbType.Char, 500);
cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string strMessage = (string) cmd.Parameters["@ERROR"].Value;
con.Close();
return strMessage;
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
}
#endregion

Here if you observe above functionality I am getting all the parameters by simply creating BEL objBELUserDetails. If we create one entity file we can access all parameters through out our project by simply creation of one object for that entity class based on this we can reduce redundancy of code and increase re usability

Observe above code have u seen this function before? in BLL.CS i said i will explain it later got it in DAL.CS I have created one function InsertUserInformation and using this one in BLL.CS by simply creating one object of DAL in BLL.CS.

Here you will get one doubt that is why BLL.CS we can use this DAL.CS directly into our code behind  we already discuss Business logic layer provide interface between DAL and Application layer by using this we can maintain consistency to our application.

Now our Business Logic Layer is ready and our Data access layer is ready now how we can use this in our application layer write following code in your save button click like this


protected void btnsubmit_Click(object sender, EventArgs e)
{
string Output = string.Empty;
if (txtpwd.Text == txtcnmpwd.Text)
{
BEL objUserBEL = new BEL();

objUserBEL.UserName = txtuser.Text;
objUserBEL.Password = txtpwd.Text;
objUserBEL.FirstName = txtfname.Text;
objUserBEL.LastName = txtlname.Text;
objUserBEL.Email = txtEmail.Text;
objUserBEL.Phoneno = txtphone.Text;
objUserBEL.Location = txtlocation.Text;
objUserBEL.Created_By = txtuser.Text;
BLL objUserBLL = new BLL();
Output = objUserBLL.InsertUserDetails(objUserBEL);

}
else
{
Page.RegisterStartupScript("UserMsg", "<Script language='javascript'>alert('" + "Password mismatch" + "');</script>");
}
lblErrorMsg.Text = Output;
}

Here if you observe I am passing all parameters using this BEL(Entity Layer) and we are calling the method InsertUserDetails by using this BLL(Business Logic Layer)

Now run your applciation test with debugger you can get idea clearly.

I hope it helps you.

Download sample code attached

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

226 comments :

«Oldest   ‹Older   1 – 200 of 226   Newer›   Newest»
Unknown said...

Your All Coding in Blogspot is meaningfull.Nice tutorial of 3-tiers for beginner.. I Rate 5 Star

Suresh Dasari said...

thanks hyu keep visiting......

jooey said...

I am really impressed the way you make me understand.Thank you very much.Keep on bloging..

Suresh Dasari said...

thanks jooey

Anonymous said...

very nice

Anonymous said...

wheres d database?

Dejt Mi Chi said...

Hi, really great tutorial here. Before reading this I had some problems understanding when to use an entity layer or property layer. I noticed some tutorial used it, and some didnt. I believe you explained that part very clear here.

Anonymous said...

nice wesite suresh.

Anonymous said...

hi suresh tis site is very useful for me and all dotnet developers.thank u.

Kishan Thakur(Pandoh)Mandi said...

HIIII WHAT AN IDEA SR GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

Shruti said...

Hi suresh, very nice website and this topic is really very usefull..

Deepika said...

While visiting this site I'm getting interest towards subject.I feel thankful to you for that

Anonymous said...

Hai sir this rajesh from kakinada,iam working as .net developer ,Today i see the blog i am really impressed,this site is very usefull me.

Sir this is mail id:vuda.rajesh59@gmail.com please send your mail id.

Mahesh said...

nice article very useful

sattar342 said...

Thank you very much Mr. Suresh

Rahul said...

thanku ...

Anonymous said...

Hello Sir,

Thanks ... It is very helpful for all ...Keep up your Good work. I am very impressed the way you are explaining.

Ram said...

Hi Suresh,

Can you give one simple project for MVC3 application in Visual Studio 2010

Anonymous said...

where is database procedure...

Santhosh Kumar said...

thanks for your valuable information, it make ma to easy understand 3 tier architech. keep on rocks

Anonymous said...

What is need of private variables in BEL.cs as you are using public variables everywhere in your example?

Anonymous said...

Awesome..i was searching for such a good poast. thanks alot :)

Unknown said...

really nice article!

Unknown said...

Sir, how to create database for this project? i m new in this field so please explain for creating database and how to connect.

Unknown said...

Hi! Brothers, please tell me how to create database for this project.

Unknown said...

Its really easy way to understand 3-tire Arch.
I have already done but confused abt 3-tire.

Thanks Suresh...

Unknown said...

Hello suresh p-lease save me...i have lots of confusion when i writting SP for this article...i am requested to you...please tell me key points to create proc for this app..thanks

Anonymous said...

Hi Suresh, While launching the applicaton, after entering the user details its giving me an error "Procedure or function sp_userinformation has too many arguments specified."

Unknown said...

Hi Suresh, While launching the applicaton, after entering the user details its giving me an error "Procedure or function sp_userinformation has too many arguments specified."

Unknown said...

Hello Anonymous for fixing that Bug we need to pass prameter for otput...here is the Proc for that app...after writing the code once test in sqlserver only then after write sp in DAL class..

CREATE TABLE tbl_tier
(
UserName VARCHAR(30),
Password VARCHAR(30),
FirstName VARCHAR(30),
LastName VARCHAR(30),
Email VARCHAR(30),
Phoneno VARCHAR(30),
Location VARCHAR(30),
Created_By VARCHAR(30)
)
ALTER PROC sp_userinformation
(
@UserName VARCHAR(30),
@Password VARCHAR(30),
@FirstName VARCHAR(30),
@LastName VARCHAR(30),
@Email VARCHAR(30),
@Phoneno VARCHAR(30),
@Location VARCHAR(30),
@Created_By VARCHAR(30),
@ERROR VARCHAR(30) OUTPUT
)
AS
BEGIN
INSERT INTO tbl_tier VALUES(@UserName,@Password,@FirstName,@LastName,@Email,@Phoneno,@Location,@Created_By)
END



DECLARE @HN VARCHAR(30)
EXEC sp_userinformation 'SHANKAR','12345','SHANKAR','PARSHIMONI','PARSHI@GMAIL.COM','9966385883','HYDERABAD','SHANKAR', @ERROR=@HN OUTPUT
SELECT @HN


Unknown said...

hello suresh pls visit this site,i am getting one bug in BLL.cs file i,e Unable to cast object of type 'System.DBNull' to type 'System.String'...i have been fixing this bug but i coudn't do...so please drop you answer ...tanq

Unknown said...

Hello friends finally i got final result in 3 tier architectur app.but i have taken only 3 controls.i have posted entire code including proc in my blogspot...so please click this link for further details http://www.shankar-mydotnetsite.blogspot.in/

Anonymous said...

Hi this post was very nice & 200% useful for 3Tier freshers including me. This shows your technical stuff as well as reputation.
Iam expecting similar like this post for basic or freshers who are willing to learn mvc, because we & our blog fans need to update with current trend & technology.
So, Please post mvc example.
Thank you!

Sagar said...

Hi this post was very nice & 200% useful for 3Tier freshers including me. This shows your technical stuff as well as reputation.
Iam expecting similar like this post for basic or freshers who are willing to learn mvc, because we & our blog fans need to update with current trend & technology.
So, Please post mvc example.
Thank you!

Unknown said...

nice web site.... keep it up

Unknown said...

NOTICE
BEL works just for calling method of DLL(realy overhead of coding and need one extra class).

why can't we write(call dll method)in codebihind file(directly in button "Click event")?

Anonymous said...

@Shankar - Kindly add the below line after the insert statement

SET @ERROR ='success' to avoid casting error.

Anonymous said...

For a fresher like me it will be very helpful if you publish the entire code (ie), with stored procedures and database tables.

Anonymous said...

CREATE TABLE tbl_tier
(
UserName VARCHAR(30),
Password VARCHAR(30),
FirstName VARCHAR(30),
LastName VARCHAR(30),
Email VARCHAR(30),
Phoneno VARCHAR(30),
Location VARCHAR(30),
Created_By VARCHAR(30)
)
ALTER PROC sp_userinformation
(
@UserName VARCHAR(30),
@Password VARCHAR(30),
@FirstName VARCHAR(30),
@LastName VARCHAR(30),
@Email VARCHAR(30),
@Phoneno VARCHAR(30),
@Location VARCHAR(30),
@Created_By VARCHAR(30),
@ERROR VARCHAR(30) OUTPUT
)
AS
BEGIN
INSERT INTO tbl_tier VALUES(@UserName,@Password,@FirstName,@LastName,@Email,@Phoneno,@Location,@Created_By)
SET @ERROR='Success'
END

the stored procedure should look like above. You need to pass the out parameter.

Anonymous said...

do i have to create a class for each table?
i mean BEL class.

Sneha said...

Hey..dats a very easiest way you explained..
really helpfull..

Anonymous said...

Very good artical sir ........

chothani punita said...

Awesome post..I got idea about the 3 tier architecture...thank u so much sir.

I am going to develop a website----Online Examination System in asp.net with 3 tier architecture. Plz help me how can I do it as I new in asp.net, plz explain me in detail..
Thanking u.

Anonymous said...

No need to add entity layer.....
BAL and DAL are enough...

Anonymous said...

where is the code for reset button?
it is just to clear all the fields.........

Poonam said...

Vry nice description of 3 tier architecture for begginer.. Thank u!!

Anonymous said...

GUD POST

Anonymous said...

gr8

Unknown said...

hi! suresh
it'S very helpful
but, please write the stored procdure of it.

that'S awesome
thank you sir

Ameer PV Pathiramanna said...

good information thank you

Anonymous said...

fabulous article . Got a clear picture regarding entity/property layer.
Regards
Raj

Anonymous said...

Niccceeeee bro.... easiest and best one from all

Anonymous said...

realy a nice tutorial i ever seen about three tier architecture........

JaipaulEdward.Jetti said...

its very nice sir to understand easily i am thankful to u for that

ANOOP said...

haii... this post is very helpful... i want to learn more and i have some doubts.. pls give me your mailid

Anonymous said...

Hi, I like your example of three tier example .It is very easy to understand .
I have a request for you can you please tell me about stored Procedure ,So i can get best explanation.
THANKS A LOT..And keep it up

Anonymous said...

HAI


in .aspx it show error at InsertUserDetails(objUserBEL);

shos that 'BEL does not contain a definition for 'InsertUserDetails'and no extension method 'InsertUserDetails' accepting a first argument of type 'BEL' could be found

Anonymous said...

what is problem in this

chanti said...

suresh bhayya awesome simply code bhayya

sagar said...

Exactly good working by you guys....
keep it continues

Thanks to understand 3 tier arch...

Anonymous said...

very nice Mr Suresh...
i like ur demo and code too..

Anonymous said...

Mr Harshu..pls check parameter which u passed...
so u can solve ur error...

Anonymous said...

Very good article I understood it given step by step...very useful

Anonymous said...

only the thing is can u provide this article without using out parameter it is difficult to understand fresher how the value is returned? to the BLL can you brief it?

Thank in advance..

Anonymous said...

Thank u sir.....:)

Anonymous said...

Nice article .Will you pls explain how to make 3-tier architecture?

Anonymous said...

can u please upload image to folder using this same method.... please

Anonymous said...

gud one...

Anonymous said...

nice..

Unknown said...

hi Mr.suresh...........
Its very helpful to me and i have a doubt?
how can i insert the values in more than tables from windows form to database via DAL and BAL concept...Please Tell me and i am waiting for your ans

hima said...

thank u for sharing the articles.....

Unknown said...

Very clear for freshers........

Unknown said...

Very clear for freshers........

Unknown said...

Hi suresh its a perfect 3 tier architecture code and very easy to understand. please mention connection string in web.config file.

please send me how to update dropdownlist inside gridview inn rowupdating event includind database back up. My mail is rangarao58@gmail.com

Unknown said...

Hi suresh its a perfect 3 tier architecture code and very easy to understand. please mention connection string in web.config file.

please send me how to update dropdownlist inside gridview inn rowupdating event includind database back up. My mail is rangarao58@gmail.com

Anonymous said...

Hi Suresh this is a good example for but not for 3 tier

Anonymous said...

Hi Suresh this is a good example for 3 layer but not for 3 tier

Jatin said...
This comment has been removed by the author.
Jatin said...

Suresh, u r really doing a nice job..

Jatin said...

your way of explanation is really easy and efficient.. :)

Anonymous said...

Ya its good topic..
But i have one doubt on 3 tier architecture.
How to fill master and child table using 3 Tier architecture by using Transaction?
Please send me answer to this mail id frnz.jun@gmail.com

Anonymous said...

Jayant :gud 1 it actually made some thoughts clear

sureshbehera said...

its very valuable for me i want mvc demo project also plz plz plz send me on e-mail sureshbehera12@gmail.com

Unknown said...

great

Anonymous said...

Really it is a very helpful artical for beginners and I got very much help from your article in our final year project.Thanks u mr.suresh and keep updating....

Anonymous said...

hai suresh.Is it mention any connectionstring in bll.i follow u r steps.when i am trying to execute
"The connectionstring property has not been initialized" error showing in bll.

Suneel Kumar Biyyapu said...

Hai Suresh, it is much useful for me..., And It is very easy to understand your presentation.

Unknown said...

good blog sir.. easy to understand.
great job...............

Unknown said...

good blog sir.. easy to understand.
great job...............

Unknown said...

Thanks...It is Useful for me...great explaination
Thank U very Much.... :)

aspnet said...

thank you sir ,this is helpful content

Anonymous said...

Nice and Very Help Full Sir

Unknown said...

Thank you This is very helpful

Anonymous said...

u should be a great teacher..u explains in very simple manner so newer people can also get your blogs...thanks u

Unknown said...

Clearly understood what is 3-tier atchitecture . Thank you .

Unknown said...

i want coding for sign out in 3 tier architecture with session concept

Anonymous said...

Thanks Suresh,
It is realy helpful information for any .net developer and the way you explained is simply awesome...!!

Jangu Phelix said...

Hi Suresh,
I must say you are great. I visit your site almost daily, and learn at least something new everyday. Keep it up.

thinusha said...

Your All Coding in Blogspot is meaningfull.Nice tutorial of 3-tiers for beginner..

Megic Geeks Technology said...

Hello Suresh.
it is really helpfull....
keep it up.....

Unknown said...

VOUCHER:
• VOUCHER NO (PK) (VAR 30)
• DATE (VAR 10)
• PAID TO (VAR 30)
• AMOUNT (DOUBLE 30)
• REASON (VAR 45)
• AUTHORIAZED SIGNATURE (TEXT )
Voucher is the table and folling are the attribute now i want desining and store procedure with 3-tire architure with coding every thing Please help me out of the proble are mail me sunilkumar.subbu@gmail.com

Anonymous said...

Bhai.. Suresh Thoda Easy Way me 3 Tire ka Coding Nahi Hai Kya ?
Ye Samaj Me Nahi aa raha hai..
Thoda samj me aye esa kucchhh Likho na pls yaar
I m Fresher for 3 tier... to kya aap kuchh Help Kar sakte ho

Hardik-Patel said...

nice sir its impressive and keep doing this type of stuff in easy manner.
thanks a lot

pramod said...

hello my query is how to implement 3 tiers Architecture in whole asp.net project i.e if there is more than 10 form so how to implement 3 tiers architecture is there create each bal,dal for each databasse code
please solve my query

Marees said...

Nice article .Will you pls explain how to make MVC 4 ?

Anonymous said...

nice

Anonymous said...

i got error in DAL.cs nullreference was unhandled by code in connectionstring

nandy said...

ERROR***

i have initialized my dal object to null in finally block,
its showing error,
ExecuteNonQuery: Connection property has not been initialized.

nandy said...

namespace BLclass
{
public class BLPerson
{
public string RegisterUser(PersonInfo entityObj)
{
PersonDALclass dalObj = new PersonDALclass();
try
{
return dalObj.RegisterUser(entityObj);
}
catch (Exception ex)
{
throw ex;
}
finally
{
dalObj = null;

}


}
}
whats wrong in this code.

Affiliate Marketing said...

thanks alot dear suresh for your fruitful postings.

Unknown said...

good post really it is very useful for everyone .thanks a lot .awesome work by you

Unknown said...

in our webpage to bind textbox we do as

textbox1.text

what is the correct synatx for binding drop down list
mail me on my id manpreettwinkle0@gmail.com

urgent

Unknown said...

Good Job Suresh........Awesome Explanation in all your tutorials....

seema darade said...

thanks....It's good explanation.....

Anonymous said...

nice

Anonymous said...

I cannot access BEL in in DAL class... i.e . I cannot write
BEL b=new BEL() // Here BEL is not coming in intellisence ...

name said...

So good site for us..thanks this site..

Pradeep Kumar said...

its very usefull to all

Anonymous said...

Good one,Very Useful

Prav said...

Hi,

DO I need to create seperate classes for each table in BEL class ?

Unknown said...

This is one of the best site I ever seen ..

Bhusan said...

CODE FOR SAVING RADIO BUTTON (DAL,BAL & PRESENTATION LAYER)VALUE IN 3 TIER
KINDLY REPLY

jackson said...

Thanks alot suresh... awesome explanation..

Unknown said...

Really a Grate Tutorials for Freshers:)

Unknown said...

its really help full for those people who want to learn about 3-tire architectre ....thnak you very much sir....

prv said...

thanks suresh.......

Anonymous said...

very usefull to me

Anonymous said...

Easy way to learn 3-tier arch for every programmer ..................keep it up suresh

Anonymous said...

Hi this post is good to understand but how to display in the gridview please help me out

Anonymous said...

Marvelous example

Anonymous said...

very useful....great work

Unknown said...

really nice website for dotnet developer..thanks for my career

Saurabh said...

Hello Suresh,

Can you please explain, which reference is to be added to which layer.

I have added BLL reference in DLL and Application Layer. Now when am trying to add DLL reference to BLL it says A reference to DLL couldn't be added. Adding this project as a reference will cause circular dependency, and without adding DLL reference to BLL i guess we cant access the methods of DLL in BLL.

Please help.

Thanks,
Saurabh

Anonymous said...

Thank you.... its really very useful...

Anonymous said...

u are realy gr8!!!! keep it up n thnx

surya ks said...

thanks...very useful....

Anonymous said...

namespace DAL
{
public class Employee
{
int employeeID;
string lastName; // should be (20) chars only
string firstName; // should be (10) chars only
string title; // should be (30) chars only
string address; // should be (60) chars only
string city; // should be (15) chars only
string region; // should be (15) chars only
string postalCode; // should be (10) chars only
string country; // should be (15) chars only
string extension; // should be (4) chars only

public int EmployeeID
{
get
{
return employeeID;
}
set
{
employeeID = value;
}
}

public string LastName
{
get
{
return lastName;
}
set
{
lastName = value;
}
}

public string FirstName
{
get
{
return firstName;
}
set
{
firstName = value;
}
}

public string Title
{
get
{
return title;
}
set
{
title = value;
}
}

public string Address
{
get
{
return address;
}
set
{
address = value;
}
}

public string City
{
get
{
return city;
}
set
{
city = value;
}
}

public string Region
{
get
{
return region;
}
set
{
region = value;
}
}

public string PostalCode
{
get
{
return postalCode;
}
set
{
postalCode = value;
}
}

public string Country
{
get
{
return country;
}
set
{
country = value;
}
}

public string Extension
{
get
{
return extension;
}
set
{
extension = value;
}
}
}
}


in this why u have used namespace DAL and how can i create in my code.

Anonymous said...

Its really very helpful

Unknown said...

It's really very helpful. Thank you!

Anonymous said...

Hello.. Its very helpful article. But, according to my understanding, Actually 3 tier architecture means it contains Application layer, Business Layer and Data Access Layer and each layer should be in separate machines. Actually the example above illustrates N-layer architecture.. Could u please ellaborate the difference between n-tier and n-layer architecture in brief?

Suresh Goud M said...

thanks sir ...very useful

Sumit said...

One question..
As you are creating Object of DAL in BAL to get access of its method. Shouldn't we use dependency injection.
Also we can Inherit BLL from BEL
Please give your inputs

Unknown said...

Really very helpfull...........

Pulaha said...

Please help me .. i don't understand this line
cmd.Parameters.Add("@Error",sqlDbType.char,500);
sqlDbType can't exist in the current context.
I also using namespace
using System.Data;
using System.Data.SqlClient;
Yet error can seen..i don't understand.

Unknown said...

how to create a login page by giving the username and password and getting details of the registered member

Anonymous said...

Bro i understood all clearly.But my question is my web app contains more forms.so i need to connect all with DB.so Which is best method for each form one one DAL code file or one DAL code for all pages ?
Please help me,,my id : pk.suhail47@gmail.com

Anonymous said...

thanks bro........

Unknown said...

Very nice thank u very much

Unknown said...

Thank u...i got it. but

i need login page using same 3 tier architech..

Unknown said...

i will say best tute...for begineers...

Unknown said...

very nice tutorial........thanks..

Anonymous said...

hi,
i am getting error in this bll code that "object reference set to an instance of object."NUll Reference Exception.
can anyone help in this issue...
thanks in advance

yogeesha sp said...

both BEL and DTO is same?wer we BEL wether in busness entity or wer?,,please execute same proj using store procedure,,

Anonymous said...

ya..i wrote code in stored procedure also...but in bll.cs its shows error near finally...while executig...

Unknown said...

Your are created a tightly coupled 3 tired architecture. If you go to your deployment situation, it will be very hesitate. It mean every layer goes to separate server... you need to create a one service layer for communicate each layer, it will be change your entire architecture and the code.

If you have any other solution, just share your knowledge.

Anonymous said...

Nice tutorial of 3-tier architecture for beginners......

Unknown said...

which layer would JQuery fit into ? Thanks.

Unknown said...

i also liked it....
Can u post similar thing for mvc (including MVC, MVC1,MVC2,MVC3 and MVC4)

Unknown said...

Hai ! This is awesome tutorial for us.....Thank you very boddy

Unknown said...

sir plz send ppt presentation ,how we can use web services in news website
sir send me ppt rameshjoshi375@gmail.com

Anonymous said...

Thanks Suresh.

Look him, he has written really comprehensive article on 3 tier architecture - http://www.dotnetfunda.com/articles/show/2708/3-tier-architecture-in-aspnet-a-complete-article

Thanks

Unknown said...

excellent. but how to use a simple query instead of stored procedure. that is how to pass the query like select * from table do we need to create different methods for different entities? please reply soon.

Unknown said...

i got error like sp_userinformation has too many arguments specified....what does it mean?? can u plz tell me??

Anonymous said...

one of the best sites

Anonymous said...

niranjan :may be the parameters you are passing and parameters in the stored procedure is more compaired to the other one

Unknown said...

USE [Techproperty]
GO
/****** Object: StoredProcedure [dbo].[BuilderProc] Script Date: 01/10/2014 16:49:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[BuilderProc]
@uid int=null,
@BuildersName varchar(100)=null,
@Phone varchar(100)=null,
@EmailId varchar(100)=null,
@City varchar(100)=null,
@Address varchar(100)=null,
@id int=null
as
begin
if(@uid=0)
Insert into Dbbuilder (BuildersName,Phone,EmailId,City,Address,CreatedDate,Active)Values (@BuildersName,@Phone,@EmailId,@City,@Address,GETDATE(),1)
end
if(@uid=1)
begin Update Dbbuilder set BuildersName=@BuildersName,Phone=@Phone,EmailId=@EmailId,City=@City,Address=@Address,ModifiedDate=GETDATE() where Active=1 and id=@id
end
if(@uid=2)
begin update Dbbuilder set Active=0 where id=@id
end
if(@uid=3)
begin Select id,BuildersName,Phone,EmailId,City,Address from Dbbuilder where Active=1
end
if(@uid=4)
begin Select id,BuildersName,Phone,EmailId,City,Address from Dbbuilder where Active=1 and id=@id
end

if(@uid=5)
begin select BuildersName from Dbbuilder where Active=1

end
.....this is procedure

Unknown said...

Please give back up of database also.

Anonymous said...

Hi,
I have a problem with web.config file
My Connection String is stored in web.config file.Which is in UI Layer.Then How can to access my web.config file from Data Acess Layer.Please tell your suggestion .Any help would be appriciated.Thanks

Anonymous said...

Really very nice for freshers...

Anonymous said...

it was really helpful very nice article to understand 3 tire best ... thank you so much for providing this article ... it really helped me alot

Anonymous said...

Thank you Suresh...Good one

SAMIR R. BHOGAYTA said...

very nice explanation with example....thank you

Veena DhanuGowda said...

NIce one for beginners thank

Anonymous said...

Very useful for understanding.Thank you so much.

Anonymous said...

Value for time..!! Thankyou :)

Anonymous said...

simply superb

Anonymous said...

Nice articel and also we expecting more interview related question and answers from you.

Anonymous said...

Nice Article... i am really very thankful.

Unknown said...

Hi suresh I create one website in 3 tire architecture when I publish with filesystem and upload in live it give error

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'dbo.Admin.Index'.

Source Error:


Line 1: <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Index.master.cs" Inherits="dbo.Admin.Index" %>

Anonymous said...

thanks a lot...

Unknown said...

I want to insert image using 3 layer Arch. but there is a err. saying that
Operand type clash: nvarchar is incompatible with image
wha is the reason

Unknown said...

its very useful for beginners sir..........thank you

Unknown said...

Thanks very much anonymous.... god bless you

Anonymous said...

hello....sorry to say this is three layer not three tier application..........

Unknown said...

Nice tutorial....

Anonymous said...

Hi .....very gud work....very useful for beginner

Bhavesh Bhuva said...

Thank you........

Unknown said...

Very useful for me ---- Thank's a lot bro

Unknown said...

Helooooo...i want to know about the .Net for the interview perpose only..not programming totally.

Anonymous said...

Thanks for stepwise explanation....Well designed...Great Article!!!

Unknown said...

nice article...!!

Anonymous said...

very useful........

Anonymous said...

its great for 3 layer

Bhagawat007 said...

Now understanding what exactly 3 tier concepts..Thank You...

Anonymous said...

nice concept which is easy to understand

Anonymous said...

Hi,

Thanks for the article. Can you please confirm, is it possible to deploy these deliverable in three different servers? If that is the need, what is your recommendation?

Anonymous said...

very nice concept to understand 3 tier. if you an idea about MVC latest trend so its great for us.



Unknown said...

very use full article

Anonymous said...

God of asp.net

Unknown said...

Hi​ Sir,
​​
​i am udhaya kumar .Net Developer. i have a doubt "" How to display a image in gridview in three tier application using C#... Then How to display auto increment values in textbox in ​three tier application using C#​ """"


Please clear my doubt asap..


My Mail id:udhaya@igenuinesoft@gmail.com

«Oldest ‹Older   1 – 200 of 226   Newer› Newest»

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.