Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
when am creating any application just am writing all the code in a single file
 
For example:
Am creating login page in asp.net with Sql Server2008
 
how to implement in 3tire
 
give me Simple Understanding
Posted 13-Feb-13 23:03pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

First Create BEL.CS (Business Entity Layer)
 
BEL.CS
 
 
private string _UserName;
private string _Password;
 
public string UserName
{
get
{return _UserName;
}
set
{
_UserName = value;
}
}
 
public string Password
{
get
{
return _Password;
}
set
{
_Password = value;
}
}
 

Second One For DAL.CS (Data Access Layer)
 
 
//SQL Connection string 
string ConnectionString = ConfigurationManager.AppSettings["LocalConnection"].ToString();
 

public string UserInformation(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.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();
}
}
 

Third One For BLL.CSS (Business Access Layer)
 
BLL.CSS
 
public string UserDetails(BEL objUserDetails)
{
DAL objUserDAL = new DAL();
try
{
return objUserDAL.UserInformation(objUserDetails);
}
catch (Exception ex)
{
throw ex;
}
finally
{
objUserDAL = null;
}
}
 
Now In Presentation Layer
 
My Login.aspx.cs
 
 
protected void btnlogin_Click(object sender, EventArgs e)
{
try
{
string Output = string.Empty;
BEL objUserBEL = new BEL();
 
objUserBEL.UserName = txtuser.Text;
objUserBEL.Password = txtpwd.Text;
BLL objUserBLL = new BLL();
Output = objUserBLL.InsertUserDetails(objUserBEL);
Response.Redirect("Home.aspx");
}
catch(exception ex)
{
 
}
} 
 

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here is the tutorial on how to create a 3-tier architecture: Creating ASP.NET Applications with N-Tier Architecture[^]
 
and here is one example site for the same: YaBlogEngine - A Tiny Blog Engine written in ASP.NET/C#[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 499
1 Maciej Los 325
2 Sergey Alexandrovich Kryukov 234
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100