protected override void OnNavigatedFrom(NavigationEventArgs e) { if (dbConn != null) { /// Close the database connection. dbConn.Close(); } } private void Click_Login(object sender, RoutedEventArgs e) { dbConn = new SQLiteConnection(DB_PATH); SQLiteCommand sqCommand = new SQLiteCommand(dbConn); if (txtEmailaddress.Text != "") { sqCommand.CommandText = "SELECT * FROM Task Where Email=" + "\'" + txtEmailaddress.Text + "\'" + "and Password=" + "\'" + txtPassword.Password + "\'"; sqCommand.ExecuteNonQuery(); SQLiteDataReader reader = sqCommand.ExecuteReader();// exeception throws here } }