Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have the following code that calls on a remote geodatabase server. Everything is connected and working, but when I try to add a point and use featureclass.CreateFeature();, it shuts down.

At first I realized it was esriMultiPoint, but I fixed this, I remade the command lines, and created the shp2sde again. And this time I can confirm the server says it is esriGeometryPoint.

IWorkspaceEdit wse = ws as IWorkspaceEdit;
wse.StartEditing(true);
wse.StartEditOperation();
Log.Write("Feature class=" + fClass.FeatureType.ToString() + " Fieldtype=" +fClass.ShapeType.ToString());
//Get a reference to the new point object
ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint)(serverContext.CreateObject("esriGeometry.Point"));
Log.Write("Create esriGeometryPoint");
((ESRI.ArcGIS.Geometry.IGeometry)com_point).SpatialReference = ((IGeoDataset)fClass).SpatialReference;
IGeometry geometry_point = com_point as IGeometry;
Log.Write("Check geometry point type=" + geometry_point.GeometryType);
//input coords 
object tempObj;
paraMap.TryGetValue("Longi", out tempObj);
com_point.X = double.Parse(tempObj.ToString());
paraMap.TryGetValue("Lati", out tempObj);
com_point.Y = double.Parse(tempObj.ToString());
Log.Write("about to create feature");
IFeature f = fClass.CreateFeature();
Log.Write("Create feature"); //CODE NEVER GETS HERE
f.Shape = com_point;

Here's my commandline to create the table in the database... (I put dots for excluding some info).

shp2sde -o create -l mynewdata3,shape -f C:\..bla.shp -a all -i sde:sqlserver:..... -C FID,SDE,1 -s ...... -D ...... -e p -u ..... -p ......

EDIT, should have used:

shp2sde -o create -l mynewdata3,shape -f C:..bla.shp -a all -i sde:sqlserver:..... -C FID,SDE,1 -s ...... -D ...... -e pn -u ..... -p ......

The log output and ERROR:

Feature class=esriFTSimple Fieldtype=esriGeometryPoint
Create esriGeometryPoint
Check geometry point type=esriGeometryPoint
about to create feature
at ESRI.ArcGIS.Geodatabase.IFeatureClass.CreateFeature()\r\n Shapes of this entity type not allowed in this layer

EDIT: I checked with logs and saw that the feature class being used, is correct feature class too.

EDIT 2: Solved

Details about the error: http://support.esri.com/en/knowledgebase/techarticles/detail/16135

Solution: http://forums.esri.com/Thread.asp?c=159&f=1707&t=232881

share|improve this question
1  
shp2sde - If you have an argis license, may I ask why are you creating the table using shp2sde? I know it is an ESRI command, but you will be facing much less pain if you did it with ArcObjects or GP. shp2sde does things at the arcsde level (instead of the GeoDatabase level) and I wouldn't be surprised if it was slightly messed up for your release. –  Ragi Yaser Burhum Mar 20 '12 at 20:05
    
I have a limited Arc View license. So I can't administer my arcSDE database using ArcCatalog so I have to use command prompts. :S –  Dexter Mar 20 '12 at 20:15
    
AFAIK, you can still use ArcObjects to connect to an enterprise GDB even with ArcView. It will not do a license check to block you from doing that. –  Ragi Yaser Burhum Mar 21 '12 at 0:07
    
Ms and Zs also match? –  Ragi Yaser Burhum Mar 21 '12 at 1:30
    
Yes I am connecting with ArcObject Geodatabase API to a database. Everything initializes. It's just the "CreateFeature" that's broken. Something must be wrong with my shapefile, I use a spreadsheet to create it and make an X,Y table. (Yes I don't include Ms/Zs). –  Dexter Mar 21 '12 at 14:35

1 Answer 1

up vote 1 down vote accepted

Solved. The problem was that in the command line -e p was used. Which is a point.

However when you call createFeature:

IFeature f = fClass.CreateFeature();
Log.Write("Create feature"); //CODE NEVER GETS HERE
f.Shape = com_point;

the CreateFeature tries to create an empty record for shape. Which is not a point but a "null". So bad design by ESRI to not clarify such situations.

Just use sdelayer -o alter ....... -e pn in command prompt.

To modify your sde table to allow p and n types.

you can use sdelayer -o describe_long ...,...,,,,...

to check what types are allowed.

share|improve this answer
1  
+1 this is good to know. Please mark your answer as accepted. –  Kirk Kuykendall Mar 21 '12 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.