Suppose we have to find out potential $V$ at point $P$ in the given figure. I know that it can be easily done as
$$dV=\frac{k×dq}{\sqrt{(x^2+a^2)}}$$ and integrating $dq$ to $Q$. Where $k$ is a constant such that $k=\frac{4}{10^9}$. And the correct answer will be $$V=\frac{k×Q}{\sqrt{(x^2+a^2)}}$$
But my question is, I have studied that potential at any point can also be given by $$V=-\int{\vec{E}.\vec{ds}}$$. .......$(1)$
And also value of $E$ for ring at point $P$ is given as $$E=\frac{k×x×Q}{\sqrt{(a^2+x^2)^3}}$$. So by using equation $(1)$
$$V=-\int{\frac{k×x×Q.ds}{\sqrt{(a^2+x^2)^3}}}$$.
But I won't understand what is being varied i. e, which varying quantity is being expressed by $ds$. Is it is the $x$ (distance from centre along axis of ring). Suppose I assume that $x$ is being varied then I can write $ds$ as $dx$.
$$V=-k.Q\int_0^x{\frac{xdx}{\sqrt{(a^2+x^2)^3}}}$$.
But this gives me different answer than the correct one. I know that I have done something very wrong. Also I am not sure with the limits I have taken i.e from $0$ to $x$. Please help me identifying my mistake.
Responding to @Floris's comment, I have solved it as
This is that different answer. I think that my integration limits have went wrong, but I don't know the correct one. Now please help me.