Hi,

i have a user table in backend with many columns n from that i need to user the email id and password for login. I have read the data in my code using a data reader, but am not getting how to match the entered username and password by user with the backend data.
If any one can pls guide with same...
Thanks

protected void btnLogin_Click(object sender, EventArgs e)
    {
        //string cmd1 = ("Select email, password from fwm_user");
        //DataSet ds;
        //SqlDataAdapter da = new SqlDataAdapter(cmd1, conn1);
        //da.Fill(ds, "fwm_user");
        
        SqlCommand cmd1 = ("Select email, password from fwm_user");  
        SqlDataReader dr;
        dr = cmd1.ExecuteReader();

        if (dr.Read())
        { 
            if(dr.GetString ........??????????????
        }
        
            }

Recommended Answers

All 2 Replies

SqlConnection con = new SqlConnection("Data Source=SECANT-B0A227A3;Initial Catalog=Logins;integrated security=True;");
        SqlCommand cmd = new SqlCommand("select email,password from login", con);
        con.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
           
            if ( txtboxemail.Text.Trim()==rdr[0].ToString().Trim() && textboxpassword.Text.Trim()==rdr[1].ToString().Trim())
            {
                Response.Redirect("~/Home.aspx");
            }
        }

Thank you so much. Now i can proceed further.[:)]

SqlConnection con = new SqlConnection("Data Source=SECANT-B0A227A3;Initial Catalog=Logins;integrated security=True;");
        SqlCommand cmd = new SqlCommand("select email,password from login", con);
        con.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
           
            if ( txtboxemail.Text.Trim()==rdr[0].ToString().Trim() && textboxpassword.Text.Trim()==rdr[1].ToString().Trim())
            {
                Response.Redirect("~/Home.aspx");
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.