Is there a way to switch to another theme?

switch_theme() is the function you need but this…

why is someone changing the stylesheet and no longer changing the
theme?

… indicates a misunderstanding. You provide the $stylesheet as an argument but you are switching the theme as a whole not just the stylesheet. And, for reasons unknown, $stylesheet isn’t the stylesheet. It is:

$stylesheet is the name of your folder slug. It’s the same value that
you’d use for a child theme, something like twentythirteen.

https://codex.wordpress.org/Function_Reference/switch_theme

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)