The material is removed if you set IPartDoc::SetMaterialPropertyName2("", "", "")
To get the full path of the database you have to add some more code... see this example.
I have also found that using multiple databases with same name might make SolidWorks to pick the wrong material.
And note that the material might be different for each configuration in the part, therefore I would recommend that you loop this thru for each configuration.
Great, got it working
It was the: IPartDoc::SetMaterialPropertyName2("", "", "") thing i was missing.
Also that 'GetMaterialDatabases' could come in handly.