Click here to Skip to main content
15,915,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
suppose if the password v type in the text box does not match wid the one in sql.. can anyone give the code for displayin that error message in label. Here we are not using any ID
Posted

 
Share this answer
 
Comments
Nihal Hussain 24-Dec-11 5:08am    
without using stored procedur is der ny method.. I hv done encryption 4 d password
public void login()
{
string strLoginId;
        string strPassword;
        DataSet oDs = null;
        bool IsRemember = chkRememberMe.Checked;
 
//this is class file where you will be write your code for get the information to database
   CityBusinessLogics.AdminLogics oAdmin = new CityBusinessLogics.AdminLogics();
        strLoginId = txtUsername.Text.Trim();
        strPassword = txtPassword.Text.Trim();
        HttpCookie OnlineCookie = new HttpCookie("OnlineCookie");
 
        if (Page.IsValid)
        {
            try
            {
                oDs = oAdmin.ValidateAdminLogin(strLoginId, strPassword);
                if (oDs.Tables[0].Rows.Count <= 0)
                {
                    lblMessage.Text = "Wrong LoginId or Password !!";
                    lblMessage.Visible = true;
                }
                else if (IsRemember)
                {
                    string EnUserName, EnPwd;
                    EnUserName = oAdmin.base64Encode(strLoginId);
                    EnPwd = oAdmin.base64Encode(strPassword);
 
                    OnlineCookie.Values.Add("UserName", EnUserName);
                    OnlineCookie.Values.Add("Password", EnPwd);
                   
 
                    Response.Cookies.Add(OnlineCookie);
                    OnlineCookie.Expires = DateTime.Now.AddDays(15);
 
                    Session["Admin"] = strLoginId;
                   
                 if (Session["Admin"].ToString() == "admin")
                       Response.Redirect("AdminChangePassword.aspx");
                   else
                        Response.Redirect("RoleTask.aspx");
 
                }
                else
                {
                    //OnlineCookie.Values.Add("UserName",string .Empty);
                    //OnlineCookie.Values.Add("Password", string.Empty);
                    //OnlineCookie.Values.Add("Roles", string.Empty);
                    //Response.Cookies.Add(OnlineCookie);
                    //OnlineCookie.Expires = DateTime.Now.AddMinutes(5);
                    Session["Admin"] = strLoginId;
                   // Session["Roles"] = oDs.Tables[0].Rows[0]["RoleIds"].ToString();
                  if (Session["Admin"].ToString() == "admin")
                      Response.Redirect("AdminChangePassword.aspx");
                   else
                        Response.Redirect("RoleTask.aspx");
                }
 
            }
            catch
            {
                lblMessage.Text = "Login failed.";
                lblMessage.Visible = true;
            }
        }
 
Share this answer
 
Comments
Nihal Hussain 24-Dec-11 5:20am    
@ManavGuru is der any single tier code.. here Im working on single tier

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900