Esempio n. 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            con = new SqlConnection(connection);
            string         query = "SELECT * FROM Users where Email = '" + cbb_Email.Text + "' AND Password = '******'";
            SqlDataAdapter sda   = new SqlDataAdapter(query, con);
            DataTable      dtb   = new DataTable();

            sda.Fill(dtb);

            if (dtb.Rows.Count == 1)
            {
                MessageBox.Show("Login successfully");
                MainOptions mainOptions = new MainOptions();
                mainOptions.Show();
            }
            else
            {
                MessageBox.Show("Login unsuccessfully");
            }
        }
Esempio n. 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection con   = new SqlConnection("Data Source=DESKTOP-Q1QGNFE;Initial Catalog=module5a;Integrated Security=True");
            string        query = "SELECT ID FROM Users where Email = '" + txtUserName.Text + "' AND Password = '******'";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader sdr = cmd.ExecuteReader();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    user_id = sdr.GetInt32(0);
                }
                MessageBox.Show("Login successfully " + user_id.ToString());
                MainOptions mainOptions = new MainOptions();
                mainOptions.Show();
            }
            else
            {
                MessageBox.Show("Login unsuccessfully");
            }
        }