Nanocrystals of CdSe and CdS have been prepared in sol-gel films of TiO2 and ZrO2 by reaction of the sol-gel precursors containing Cd-ions with solutions of either selenosulfate or sulfide ions. The sol-gels were found to protect the nanocrystals against phase transformation during annealing and mechanisms for this effect were discussed.