You will need both sine and cosine:

y= A cos(x)+ B sin(x)

y'= -Asin(x)+ Bcos(x)

y"= -Acos(x)- Bsin(x)

y"- 6y+ 9y= -Acos(x)- Bsin(x)- 6Asin(x)+ 6Bcos(x)+ 9Acox(x)+ 9Bsin(x)

= (-A+ 6B+ 9A) cos(x)+ (-B- 6A+ 9B) sin(x)

= (8A+ 6B) cos(x) + (8B- 6A) sin(x)= 50 sin(x)

Solve 8A+ 6B= 0, 8B- 6A= 0 for A and B.