Dear All,
I've written the following code trying to copy the subtypes of a feature class, but got the following error message in the set_Domain method, could anyone help point out what's wrong?
Error message: "This database does not support null default values."
Program:
private bool copySubTypes(IFeatureLayer pFeatureLayer, IFeatureClass fgdbFeatureClass, IWorkspace fgdbWorkspace)
{
if (pFeatureLayer == null || pFeatureLayer.FeatureClass == null) return true;
ISubtypes subtypes = (ISubtypes)pFeatureLayer.FeatureClass;
ISubtypes fgdbSubTypes = (ISubtypes)fgdbFeatureClass;
IWorkspaceDomains fgdbWSdomain = (IWorkspaceDomains)fgdbWorkspace;
if (!subtypes.HasSubtype) return true;
fgdbSubTypes.SubtypeFieldName = subtypes.SubtypeFieldName;
IEnumSubtype enumsubtype;
int subtypeCode;
string subtypeName;
IFields pFields = pFeatureLayer.FeatureClass.Fields;
enumsubtype = subtypes.Subtypes;
enumsubtype.Reset();
subtypeName = enumsubtype.Next(out subtypeCode);
while (subtypeName != null)
{
fgdbSubTypes.AddSubtype(subtypeCode, subtypeName);
for (int iCnt = 0; iCnt < pFields.FieldCount; iCnt++)
{
string sFieldName = pFields.get_Field(iCnt).Name;
object defVal = subtypes.get_DefaultValue(subtypeCode, sFieldName);
if (defVal.ToString().Length > 0)
{
fgdbSubTypes.set_DefaultValue(subtypeCode, sFieldName, defVal);
}
IDomain pDomain = subtypes.get_Domain(subtypeCode, sFieldName);
if (pDomain != null)
{
IDomain fgdbDomain = fgdbWSdomain.get_DomainByName(pDomain.Name);
if (fgdbDomain == null)
{
return false;
}
else
{
fgdbSubTypes.set_Domain(subtypeCode, sFieldName, fgdbDomain);
}
}
}
subtypeName = enumsubtype.Next(out subtypeCode);
}
return true;
}
Bila