This project has moved and is read-only. For the latest updates, please go here.

Howto add rows to a featuredatatable

Topics: Data Access, SharpMap v0.9 / v1.x
Jan 31, 2009 at 10:39 PM
Hi All,

I want to append featura data rows to an existing feature data table by use of:

_FDTIntersection.Rows.Add (ds.Tables[0].DefaultView.Table.Rows);

Always I get a "System.NotSupportedException". The _FDTIntersection is an object (not null), ds is a dataset type of SharpMap.Data.FeatureDataSet with one table and some rows.

While looping through any functions I like to add the results to the feature data table. So, what is the right way to adding rows?

Please give me some suggestions. Thanks in advance.

I'm using v0.9
Feb 2, 2009 at 6:29 PM
Hi puNk,
something like :

public static void ImportRows(FeatureDataTable source, FeatureDataTable target)
            foreach(FeatureDataRow r in source.Rows)
                FeatureDataRow newRow = source.NewRow();
                newRow.Geometry = r.Geometry.Clone();
                newRow.ItemArray = r.ItemArray;

will work as long as source and target have the same schema. You can then use it like:
ImportRows(ds.Tables[0], _FDTIntersection);
hth jd

Feb 2, 2009 at 9:28 PM
YES, a helpful approach! Now it works.

Thanks, johndiss.