Пример #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection  sqlcon  = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Amanda Bakalarczyk\source\repos\EARS\EARS\EARS_DB.mdf;Integrated Security=True;Connect Timeout=30");
            String         query   = "SELECT * FROM Login_Table WHERE username ='******' AND password = '******'";
            SqlDataAdapter adapter = new SqlDataAdapter(query, sqlcon);
            DataTable      dtbl    = new DataTable();

            adapter.Fill(dtbl);

            if (dtbl.Rows.Count == 1)
            {
                Main_Form main = new Main_Form();
                this.Hide();
                main.Show();
            }

            else
            {
                MessageBox.Show("Incorrect username or password");
            }
        }