[fdo-users] FDO error : cannot apply schema no schema was specified

nav navin.pro at gmail.com
Thu Apr 4 04:20:01 PDT 2013


While compiling the sample code present in FDODevGuide.pdf, pg 77,78,79 for
creation Feature schema table in PosggreSQL, i am getting following
exception Message "Schema SampleFeatureSchema has error. Cannot apply it."

Any idea what causes such an exception error?
Part of the code: 

if(FdoConnectionState_Open == state)
	{
		try 
		{
			// Create the ApplySchema command
			FdoPtr<FdoIApplySchema> sampleApplySchema ;
			sampleApplySchema = (FdoIApplySchema
*)fdoConnection->CreateCommand(FdoCommandType_ApplySchema);
			// Create the feature schema
			FdoPtr<FdoFeatureSchema> sampleFeatureSchema;
			sampleFeatureSchema = FdoFeatureSchema::Create(L"SampleFeatureSchema",
L"Sample Feature Schema Description");
			// get a pointer to the feature schema's class collection
			// this object is used to add classes to the schema
			FdoPtr<FdoClassCollection> sampleClassCollection;
			sampleClassCollection = sampleFeatureSchema->GetClasses();
			// create a feature class, i.e., a class containing a geometric
			// property set some class level properties
			FdoPtr<FdoFeatureClass> sampleFeatureClass;
			sampleFeatureClass = FdoFeatureClass::Create(L"SampleFeatureClass",
L"Sample Feature Class Description");
			sampleFeatureClass->SetIsAbstract(false);
			// get a pointer to the feature class's property collection
			// this pointer is used to add data and other properties to the	class
			FdoPtr<FdoPropertyDefinitionCollection> sampleFeatureClassProperties;
			sampleFeatureClassProperties = sampleFeatureClass->GetProperties();
			// get a pointer to the feature schema's class collection
			// this object is used to add classes to the schema
			//FdoPtr<FdoClassCollection> sampleClassCollection2;
			//sampleClassCollection2 = sampleFeatureSchema->GetClasses();
			// get a pointer to the feature class's identity property collection
			// this property is used to add identity properties to the feature
			// class
			FdoPtr<FdoDataPropertyDefinitionCollection>
sampleFeatureClassIdentityProperties;
			sampleFeatureClassIdentityProperties =
sampleFeatureClass->GetIdentityProperties();
			// create a data property that is of type Int32 and identifies
			// the feature uniquely
			FdoPtr<FdoDataPropertyDefinition> sampleIdentityDataProperty;
			sampleIdentityDataProperty =
FdoDataPropertyDefinition::Create(L"SampleIdentityDataProperty", L"Sample
Identity Data Property Description");
			sampleIdentityDataProperty->SetDataType(FdoDataType_Int32);		
			sampleIdentityDataProperty->SetReadOnly(false);
			sampleIdentityDataProperty->SetNullable(false);
			sampleIdentityDataProperty->SetIsAutoGenerated(false);
			// add the identity property to the sampleFeatureClass
			sampleFeatureClassProperties->Add(sampleIdentityDataProperty);
			sampleFeatureClassIdentityProperties->Add(sampleIdentityDataProperty);
			// create a data property that is of type String and names the
			// feature
			FdoPtr<FdoDataPropertyDefinition> sampleNameDataProperty;
			sampleNameDataProperty =
FdoDataPropertyDefinition::Create(L"SampleNameDataProperty", L"Sample Name
Data Property Description");
			sampleNameDataProperty->SetDataType(FdoDataType_String);
			sampleNameDataProperty->SetLength(64);
			sampleNameDataProperty->SetReadOnly(false);
			sampleNameDataProperty->SetNullable(false);
			sampleNameDataProperty->SetIsAutoGenerated(false);
			// add the name property to the sampleFeatureClass
			sampleFeatureClassProperties->Add(sampleNameDataProperty);
			// create a geometric property
			FdoPtr<FdoGeometricPropertyDefinition> sampleGeometricProperty;
			sampleGeometricProperty =
FdoGeometricPropertyDefinition::Create(L"SampleGeometricProperty", L"Sample
Geometric Property Description");
			sampleGeometricProperty->SetGeometryTypes(FdoGeometricType_Surface);
			sampleGeometricProperty->SetReadOnly(false);
			sampleGeometricProperty->SetHasMeasure(false);
			sampleGeometricProperty->SetHasElevation(false);
			// add the geometric property to the sampleFeatureClass
			sampleFeatureClassProperties->Add(sampleGeometricProperty);
			// identify it as a geometry property
			sampleFeatureClass->SetGeometryProperty(sampleGeometricProperty);
			// add the feature class to the schema
			sampleClassCollection->Add(sampleFeatureClass);
			// point the ApplySchema command at the newly created feature
			// schema and execute
                       
sampleApplySchema->SetFeatureSchema(sampleFeatureSchema);
			sampleApplySchema->Execute();
		}
		catch (FdoException *ex)
		{
			FdoString *str = ex->GetExceptionMessage();//"Schema Sample Feature
Schema has error. Cannot apply it."
			ex->Release();
			
		}
	



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/FDO-error-cannot-apply-schema-no-schema-was-specified-tp5044538.html
Sent from the FDO Users mailing list archive at Nabble.com.


More information about the fdo-users mailing list