Hi Leslaw,
Beware: D is the partial derivative function, and should not be used as a variable/parameter/user-function name. (Best to avoid single capitals and starting user-symbol names with capitals, when possible.)
That said, I do not get ComplexInfinity for either code in your post (neither on V13.3.1, MacOS nor on wolframcloud.com).
I get a simpler result for the first one, using Gianluca's assumption, from
resA = DSolve[
u''[x] - (s/D)*u[x] == -(k/D)*(u0/s)*(1 - Exp[-Sqrt[s/D]*x]) /.
D -> B, (* changed D to B *)
u[x], x, Assumptions -> B > 0]
It might not be any help. If you're using an older version, prehaps try upgrading or wolframcloud.com.