I'm wondering if you can tell me what the cause of this exception is. I attached a screen shot of the error.
I'm trying to write an export routine to take a SQLServer table reprsented by a MsSql2008FeatureLayer
and load those features into a shape file represented by a ShapeFileFeatureLayer.
Here is a small sample of what I'm trying to do so far:
MsSql2008FeatureLayer sql2008Layer = new MsSql2008FeatureLayer(connectString, "CurrentField_TEST", "GEO_ID"); ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, @"C:\WKT.shp", shapeFileColumns, System.Text.Encoding.UTF8, OverwriteMode.Overwrite); //ShapeFileFeatureLayer.BuildRecordIdColumn(@"C:\WKT.shp", "GEO_ID", BuildRecordIdMode.Rebuild); ShapeFileFeatureLayer shapes = new ShapeFileFeatureLayer(@"C:\WKT.shp", ShapeFileReadWriteMode.ReadWrite); //ShapeFileFeatureLayer.BuildIndexFile(@"C:\WKT.shp"); shapes.Open(); sql2008Layer.Open(); sql2008Layer.MakeAllGeometriesValid(); Collection<feature> sqlServerFeatures = sql2008Layer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); foreach (Feature item in sqlServerFeatures) { //filter columns to matching columns only Dictionary tempCollection = (from x in shapes.FeatureSource.GetColumns().AsQueryable() from y in item.ColumnValues.AsQueryable() where x.ColumnName == y.Key select y).ToDictionary(x =>x.Key, x=>x.Value); Console.WriteLine(item.GetWellKnownType().ToString()); if (item.GetWellKnownType() == WellKnownType.Multipolygon || item.GetWellKnownType() == WellKnownType.Polygon) { BaseShape shape = item.GetShape().CloneDeep(); //Do some eidit on the shape //shape.Id = item.Id; Feature newFeature = new Feature(shape, tempCollection); System.Windows.Forms.MessageBox.Show(newFeature.IsValid().ToString()); shapes.EditTools.BeginTransaction(); shapes.FeatureSource.AddFeature(newFeature); TransactionResult result = shapes.EditTools.CommitTransaction(); foreach (var item2 in result.FailureReasons.AsQueryable()) { System.Windows.Forms.MessageBox.Show(item2.Value); } } } sql2008Layer.Close(); shapes.Close();
The error occurs on the CommitTransaction method call. Any ideas of what my problem is or do you have a better routine to accomplish an export of a SQL Server 2008 table to a shape file that represents that SQL Server data?
1538-Exception.JPG (27 KB)