How to Navigate in UWP to another xaml page by clicking a button?

242 Views Asked by At

I am trying to validate user data and when it is correct navigate to another xaml page. what I have, it and show the MainPage which is the Login window but when I enter data and click the button it closes the window, it's not checking the user input.

Here is what I have:

        private void Login_Click(object sender, RoutedEventArgs e)
       {
            Connection.Open();
            // sda = new MySqlDataAdapter("select count(*) from customers where Name = '" + loginName.Text + "' and Password = " + password.Password +"", Connection);
            string query = "SELECT * FROM customers WHERE Name = '" + loginName.Text + "' and Password = '" + password.Password + "'";
            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = query;
            MySqlDataAdapter sda = new MySqlDataAdapter(query, Connection);
            DataTable dt = new DataTable();
            sda.Fill(dt);
           


            if (dt.Rows.Count == 1)
            {
                this.Frame.Navigate(typeof(BlankPage1));

                /* BlankPage1 main = new BlankPage1();
                main.Show();
                this.Hide();
                Connection.Close(); */
            }
            else
            {
                message.Text = "Wrong Name or Password! Please, try again!";
                /* var messageDialog = new MessageDialog("Wrong Name or Password");
                await messageDialog.ShowAsync(); */
            } 
            Connection.Close(); 
       }

The commented statements are different things that I was trying.

Please, I need help to find out the problem, I will really appreciate any help.

Thank you in advance!

0

There are 0 best solutions below