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