Exemplo n.º 1
0
        private void signin_Click(object sender, EventArgs e)
        {
            try
             {
                 string myconn = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Daljeet\Documents\Visual Studio 2013\Projects\Quiz\Quiz\Database1.mdf;Integrated Security=True;Connect Timeout=30";
                 SqlConnection con = new SqlConnection(myconn);

                 SqlCommand command = new SqlCommand(
            "Select * from Student_Info where Username='******' and Password='******';", con);

                 SqlDataReader myReader;
                 con.Open();
                 myReader = command.ExecuteReader();
                 int count = 0;
                 while (myReader.Read())
                 {
                     count = count + 1;
                 }
                 if (count == 1)
                 {
                     welcome f2 = new welcome();
                     f2.Show();
                     this.Hide();
                 }
                 else if (count > 1)
                 {
                     MessageBox.Show("Duplicate username and password.. Access denied");

                 }
                 else
                     MessageBox.Show("Username and password is not correct.. Please try again");

                 con.Close();

             }
             catch (Exception Exception)
             {
                 MessageBox.Show(Exception.Message);
             }
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     welcome f2 = new welcome();
     f2.Show();
     this.Close();
 }