Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please i want C#.net code for log in page nd sql is used as back end.....
Posted

 
Share this answer
 
 SqlConnection con = new SqlConnection(@"Data Source=.\Aroona;Initial Catalog=ACSDatabase;Integrated Security=True;Pooling=False");
SqlDataAdapter loginadp = new SqlDataAdapter("SELECT count(*) FROM Login WHERE username = '" + uName.Text + "' AND password = '" + pWord.Text + "' ", con);
            
DataTable dt = new DataTable();
loginadp.Fill(dt);
            
           
if (dt.Rows[0][0].ToString() == "1")
      {
         if (uName.Text == "Admin")
             {
                 MPageAdmin mpa = new MPageAdmin();
                 mpa.Show();
                 this.Hide();
             }
          else
             {
                  Main_Page mp = new Main_Page(this.UserName);
                  mp.Show();
                  this.Hide();
              }
       }
else
       {
           label4.Visible = true;
           label4.Text = "Username or Password Incorrect!";
        }


This works for me.
 
Share this answer
 
v5

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