Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string username = textBox1.Text;
            string pass = textBox2.Text;
            cmd = new SqlCommand("select * from the user_login where username ='" + username + "'", con);
            dr = cmd.ExecuteReader();
            while(dr.Read())
            {
                if((username==dr[0].ToString())&&(pass==dr[1].ToString()))
                {
                    string acc=dr[2].ToString();
                    Class1.access=acc;
                    Form2 mf = new Form2();
                    mf.Show();
                }
                else
                {
                MessageBox.Show("Unauthorized access");
                }
                con.Close();
Posted
Updated 22-Jan-10 6:35am
v3

Could you post the connection creation code as well?
 
Share this answer
 
Storing passwords as plain text is bad security practice. You should store passwords using a one-way hash with a salt. Please edit your post to add the exception details.
 
Share this answer
 
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


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