Hello,
I'm trying to edit a personal geodatabase (ESRI) using the PersonalGeoDatabaseFeatureLayer. The layer renders great and I'm able to edit a column value but I'm not able to persist those changes. Following an example on how to edit a shapefile's attributes I attempted the following:
LayerOverlay overlay = new LayerOverlay();
MapControl.Overlays.Add(overlay);
PersonalGeoDatabaseFeatureLayer geoLayer = new PersonalGeoDatabaseFeatureLayer(@"C:\Users\matt.conrad\Desktop\CheckOut_Output.mdb", "Id;
geoLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City7;
geoLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
overlay.Layers.Add(geoLayer);
geoLayer.FeatureSource.Open();
var structures = geoLayer.FeatureSource.GetAllFeatures(new List<string>() { "Id", "BirthYear" });
// edit a feature's attribute
Feature sample = structures.SingleOrDefault(st => st.Id == "{cfcbcd6e-363c-41bb-8a94-caa29d09e9cd}");
sample.ColumnValues["BirthYear"] = "1904";
// exception thrown here (the EditTools object is NULL)
geoLayer.EditTools.BeginTransaction();
// I tried this instead of the line above and a differenct exception is thrown ("the FeatureSource is not editable")
geoLayer.FeatureSource.BeginTransaction();
geoLayer.EditTools.Update(sample);
geoLayer.EditTools.CommitTransaction();
geoLayer.FeatureSource.Close();
Any suggestions on how I can persist these changes? I would also like to be able to edit the geography as well but I thought I'd start here.
Surprisingly I haven't found any similar questions in the forums. I thought more people might be trying this.
Thanks,
Matt