Full width home advertisement

Post Page Advertisement [Top]

See my previous post insert,update,and delete with 3 tier in asp .net
how to create tree tire.


you must have craate database 

field...  id (int) autoincreament
            email_id varchar(100),

            pass varchar(100)

I used store procedure in this example.....for login

step 1.Design new page User name and Password..Like this.



Step:2-In DAL Class Write this code

 public int login(bal bl)
    {
        con.Open();
        cmd = new SqlCommand("login", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("email_id", bl.email_id);
        cmd.Parameters.AddWithValue("pass", bl.pass);
        bl.id = Convert.ToInt32(cmd.ExecuteScalar());
        con.Close();
        return bl.id;

    }

Login is store procedure you can write direct query

select * from login where email_id=@email_id and pass=@pass



Step:3-In Bal Class Write This Code

define propert.....
public class bal
{
dal dl= new dal;
public int email_id { get; set; }
public int pass { get; set; }
}

  public int login1(bal bl)
    {
        return dl.login(bl);
    }

Step:4- On butten Click Event Write This Code

 protected void Button1_Click(object sender, EventArgs e)
    {    
       public int id { set; get; }
        bl.email_id = TextBox3.Text;
        bl.pass = TextBox4.Text;
        int id=  bl.adminlo(bl);
    if (id> 0)
    {
     
        Session["user"] = TextBox3.Text;
        Session["pass"] = TextBox4.Text;
        Response.Redirect("Default.aspx");
    }
    else
    {
        Label2.Text = "Invalid User name or password";

    }
}

enjoy.........


if any query contact me



No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib