Is there a way to do this Gaussian surface problem using this other equation? The problem:

For part (i) of this problem, I began to derive an equation for it using $$E=\frac{1}{4\pi \epsilon_0}\int_V \frac{\rho s \, ds \, d\phi \, dz}{r^2}$$. But then I got to the point where I had to determine what $r$ is. I looked at the solution set and it instead uses this other equation: $$\oint \overrightarrow E \cdot d\vec a = \frac{Q_\text{enc}}{\epsilon_0}$$
I was able to use this and solve the problem just fine, but I'm curious now: if I wanted to use the first equation, what would I use for $r$?

$\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,\mathrm{Li}_{#1}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
The Surface Density $\ds{\sigma}$ is given, per unit length along the cylinder axis $\pars{~\mbox{the}\ z\mbox{-axis}~}$, by
$\ds{\sigma\pars{2\pi b} = -\rho\pars{\pi a^{2}}\implies
\sigma = -\pars{a^{2}/2b}\,\rho}$. The electric field is perpendicular to the cylinder axis. In cylindral coordinates $\ds{\pars{r,\phi,z}}$, with Gauss Law we'll consider 'sections' of length $\ds{\ell}$ along the $\ds{z}$ axis:


*

*$\ds{\color{#f00}{\large r < a}:}$
\begin{align}
E\pars{2\pi r\ell} = 4\pi\rho\pars{\pi r^{2}\ell}\implies E = {4\pi^{2}\rho r^{2}\ell \over 2\pi r\ell} = \color{#f00}{2\pi\rho r}
\end{align}

*$\ds{\color{#f00}{\large a \leq r < b}:}$
The calculation is somehow similar to the above case.
\begin{align}
E\pars{2\pi r\ell} = 4\pi\rho\pars{\pi a^{2}\ell}\implies E = {4\pi^{2}\rho a^{2}\ell \over 2\pi r\ell} = \color{#f00}{2\pi\rho\,{a^{2} \over r}}
\end{align}

*$\ds{\color{#f00}{\large r > b}:}$
The electric field vanishes out because the enclosed charge in the cylinder of length $\ds{\ell}$ vanishes out
$\ds{\implies E = \color{#f00}{0}}$.

The picture shows the electric field, in units of $\ds{2\pi\rho a}$, as a function of $\ds{r/a}$ with, for example,  $\ds{b = 3a/2}$.
