Solving ODE with substitution I have this as homework: 
$$(xy^2+y)dx+(x^2y-x)dy=0$$
I tried to solve it by substituting $z=xy+1$, but got the answer like $y=Cxe^{xy}$, which, I guess, is wrong.
I tried to solve it couple of times, but with no success.
P.S. I'm new on math.stackexchange.com. Do I need to show the whole process?
 A: Your answer $y = Cxe^{xy}$ is perfectly correct.  It is, of course, an implicit solution rather than an explicit one.  In order to get $y$ explicitly as a function of $x$ you would need the Lambert W function. 
To check that your answer is correct, write it as $C = \dfrac{x}{y} e^{xy}$ and take the differential of both sides. 
$$0 =  \dfrac{\partial}{\partial x} \left(\dfrac{x}{y} e^{xy}\right) \ dx + \dfrac{\partial}{\partial y} \left(\dfrac{x}{y} e^{xy}\right) \ dy $$
Then see that this simplifies to $0=0$ using your differential equation.
A: This equation is a typical one to be solved using the integrating multiplier. Thereby you can check the validity of your answer as well. Break it down in two parts:
$$xy^{2}dx+x^{2}ydy=0$$ 
$$ydx-xdy=0$$
For the first part it is (relatively) easy to see that the integrating multiplier is $\mu_{1}=\frac{1}{x^{2}y^{2}}$ leading to solution $xy=C_1$, hence the most general form of the multiplier shall be:
$$\mu_{1}=\frac{1}{x^{2}y^{2}}\psi_{1}\left(xy\right)$$
where $\psi_1$ is some arbitrary function
It can also be seen that the second part has integrating multiplier $\mu_{2}=\frac{1}{x^{2}}$ leading to solution $\frac{x}{y}=C_2$. Hence the most general form is
$$\mu_{2}=\frac{1}{x^{2}}\psi_{2}\left(\frac{x}{y}\right)$$
Now setting $\psi_1(t)=t$ and $\psi_2(t)=t$ we arrive at a form of the integrating multiplier that will suit both:
$$\mu=\frac{1}{xy}$$
Applying it to the given equation we obtain:
$$\left(y+\frac{1}{x}\right)dx+\left(x-\frac{1}{y}\right)dy=0$$
Rearranging:
$$d\left(xy\right)+d\left(\ln\frac{x}{y}\right)=0$$
Leading to the same solution
Method is borrowed from the book "A Course of Differential Equations" by V.V. Stepanov
