2. Condition A: $\sqrt{1+\sin \theta}=a$. Condition B: $\sin \frac{\theta}{2}+\cos \frac{\theta}{2}=a$.
(A) A is a necessary and sufficient condition for B;
(B) A is a necessary condition for B;
(C) A is a sufficient condition for B;
(D) A is neither a necessary condition nor a sufficient condition for B.
2. (D)

In condition A, it is easy to see that $a \geqslant 0$, while in condition B, $a$ may take negative values. Therefore, A does not imply B, and B does not imply A, meaning A is neither a necessary condition nor a sufficient condition for B.