Edit shape file data

May 1, 2009 at 11:58 PM
hi all

I try to edit data row for shape file i use the following code:

                  foreach (FeatureDataRow r1 in myTable1.Rows)
                  {

                      if (Convert.ToString(r1["objectid"]) == Convert.ToString(Convert.ToUInt16(trd_id)))
                      {
                          r1.BeginEdit();
                          r1["trd_name"] = "22222";
                          r1.AcceptChanges();
                          r1.CancelEdit();
                          myTable1.AcceptChanges();
                      }
                  }
but not upadetd and not give eny errors.
is this correct way to edit data in shape file or there ara best >
please help
  thanks
Coordinator
May 5, 2009 at 10:28 AM
Hi moh, Your code accepts changes to a FeatureDataRow and a FeatureDataTable (i.e marks the rows as unmodified) which is not the same as updating the shapefile. In fact sharpmap (0.9) cannot write or modify shapefiles.
NTS 1.7.x can write them though it will only write the geometry data - the attribute table is ignored (and ArcGIS cannot open it which may or may not be a problem).
SharpMap v2 can write and modify shapefiles but it is quite a jump from 0.9 and is still in development. There will be a few big bumps coming up.. hth jd