Click here to Skip to main content
12,355,591 members (72,356 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
first i am creating database and enter the values manually in the database itself.

database fields as follows; (Table name test)

Login id 1
Firs tname ram
Last name kumar
Password 123
Lastlogin time 1.31 PM

Then i am creating the Login page design as follows;

Username textbox1
Password textbox2


in the run mode i type the username 1 and password from the table (test) i am creating manually that loginid and password i am typing to this loginpage(run mode)

when i type username 1 and password 123. and click the insert button i want to show the message valid loginid and password.

suppose i type wrong username and password i want to show the message invalid login and password.

for that i how to write the code in asp.net with c sharp. it is web application project. please help me
Posted 8-Dec-12 21:49pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

string SqlConnect = System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
        SqlConnection Sqlconn = new SqlConnection(SqlConnect); 
        SqlCommand sqlcomm = new SqlCommand("select email,userpassword from signup where email='" + TextBox1.Text + "' and userpassword='" + TextBox2.Text + "'",Sqlconn);
        Sqlconn.Open();
        SqlDataReader dr = sqlcomm.ExecuteReader();
        if (dr.HasRows)
        {
            Session["email"] = TextBox1.Text;
            dr.Close();
            Sqlconn.Close();
Label1.Text = "Email-ID or Password you entered Is Valid !";
            
        }
        else
        {
 
            Label1.Text = "Email-ID or Password you entered do not match !";
            Label1.ForeColor = System.Drawing.Color.DarkGreen;
 
        }
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

protected void loginbtn_Click(object sender, EventArgs e)
        {
            string cmd = new "SELECT * FROM Users";
          
            SqlDataAdapter da = new SqlDataAdapter(cmd,con);
            DataTable dt = new DataTable();
            da.Fill(dt);
 
            string msg = "";         
 
            foreach(DataRow dr in dt.Rows)
            {
                if(unameTxt.Text == dr["username"].ToString() && pswdTxt.Text == dr["password"].ToString())
                  msg = "Success";
                else
                  msg = "Error";
                 
            }
        }
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Collapse | Copy Code

protected void login_Click(object sender, EventArgs e)
{
string cmd1 = "SELECT * FROM ACC";

SqlDataAdapter da = new SqlDataAdapter(cmd1,con);
DataTable dt = new DataTable();
da.Fill(dt);



foreach(DataRow dr in dt.Rows)
{
if(unameTxt.Text == dr["username"].ToString() && pswdTxt.Text == dr["password"].ToString())
messagebox.show("login successfuly");
else
messagebox.show("login failed");

}
}
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100