teir 3 programming style with example [Resolved]

Posted by Neha-kapoor under ASP.NET on 7/24/2011 | Points: 10 | Views : 1463 | Status : [Member] | Replies : 2
hallo to all
i want to insert program with tier 3 programming style
not use store procedure
any body help me

thanks


Responses

Posted by: SheoNarayan on: 7/24/2011 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Hi Neha,

Read this http://www.dotnetfunda.com/articles/article71.aspx

Also download this video that demonstrate the flow of creating 3-tier architecture http://www.myfunda.net/tutorials/itfc/3-TierArchitecture-Video.zip.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Neha-kapoor, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rickeybglr on: 7/25/2011 [Member] Starter | Points: 25

Up
0
Down
recently i worked on 3-tier, may be ths code wud help u out...
.aspx code- u need to create 3 text box with following labels and id 's
<table>
<tr><td>
<asp:Label ID="lblUName" CssClass="font" runat="server" Text="user name"></asp:Label> </td>
<td> <asp:TextBox ID="txtUName" Width="150px" runat="server"> </asp:TextBox> </td> </tr>
<tr> <td> <asp:Label ID="lblEmail" CssClass="font" runat="server" Text="email:"></asp:Label> </td>
<td> <asp:TextBox ID="txtEmail" Width="150px" runat="server"></asp:TextBox></td> </tr>
<tr> <td> <asp:Label ID="lblPswd" CssClass="font" runat="server" Text="password:"></asp:Label> </td>
<td> <asp:TextBox ID="txtPswd" Width="150px" runat="server"></asp:TextBox> </td>


.cs or UI layer code

protected void btnSubmitClick(object sender, EventArgs e)
{
// logic is the name of BL layer
logic objBAL = new logic(); // Instantiate buisness layer class(BAL) object
try
{
string strUserName = txtUName.Text;
string strEmail = txtEmail.Text;
string strPassword = txtPswd.Text;
objBAL.registration(strUserName, strEmail, strPassword);
} catch{----}
============================
BAL code (buisness layer)
public class logic
{
public int registration(string strUserName, string strEmail,string strPassword)

{ //datalayer is the name of datalayer class
datalayer obj = new datalayer(); //creating connection class object(DAL)
try
{
return obj.registration(strUserName, strEmail, strPassword);
}catch(-----)
}
======================
datalayer class code

public class datalayer
{

int iRedirect = 0;
private SqlDataAdapter myAdapter;

SqlConnection sqlconnection = new SqlConnection("Data Source=.;Initial Catalog=db_name;Integrated Security=true");//creating connection
public int registration(string strUserName,string strEmail,string strPassword)
sqlconnection.Open(); //open connection
try
{SqlCommand cmdinsert = new SqlCommand("insert query....", sqlconnection);
cmdinsert.CommandType = CommandType.Text; //specifying command type
//pass or set the values according to ur column names
int iRedirect = cmdinsert.ExecuteNonQuery(); //
if(iRedirect=1)
{..sucessfull}
else
...insertion fail


Neha-kapoor, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response