How to determine when my theme is deactivated?

http://www.krishnakantsharma.com/2011/01/activationdeactivation-hook-for-wordpress-theme/#

Pretty good writeup for activation and deactivation

Same thing is here on SE
Theme Activate Hook

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