In this work, a potential semiorganic nonlinear optical candidate NH4B[D-(+)-(C4H4O5)]2·H2O (NBC) has been studied using Density Functional Theory. The origin of the second harmonic generation (SHG) effect of NBC crystals for the NH4B[D-(+)-(C4H4O5)]2·H2O molecular complex is explained by employing a combination of the density of states, SHG density and molecular orbital analysis. It reveals a way in which the organic and ammonium groups affect the SHG processes in a significantly different manner in the crystals and the molecular complex. In particular, the role of hydrogen bonding interaction in influencing the electronic structure and nonlinear optical properties is explicitly identified and explained.