Reaction of an alkyl halide with silver nitrite
On treating ethanolic solution of haloalkane with silver nitrite ($\ce{Ag-O-N=O}$), nitroalkane is formed because since the bond between $\ce{Ag-O}$ is covalent, the lone pair on nitrogen acts as an attacking site for nucleophilic substitution.
$$\ce{R-X + AgNO2 -&gt; R-NO2 + AgX}$$
But on the other hand if haloalkane is treated with potassium nitrite ($\ce{KNO2}$), alkyl nitrite is formed as major product because since the bond between $\ce{K-O}$ is ionic in nature, the negative charge on oxygen serves as an attacking site.
$$\ce{R-X + KNO2 -&gt; R-O-N=O + KX}$$