join external table ?

Feb 24, 2011 at 7:12 PM
Edited Feb 27, 2011 at 9:12 AM


I need to get values from a mysql or access database to symbolize features and wonder what would be the best way. I have only ids in the shapefile and corresponding values are stored in the database. I would like to display resulting attributes as labels or symbolize features according to feature attribute values.

So I'm searching the best way to do a join between shapefile and database, something like GIS usually do.

- I saw that there is a join method but which uses excel, so it's not mysql or access, and I would prefer not to generate the excel file programmatically (which is very long).

- I can copy the shp and and generate a new dbf before loading the feature, but it's not very nice,

- I can use featureset.colums.add and add the missing columns, fill them one by one after according to the id, but it doesn't seem very powerful,

So far I didn't find something else, so I would appreciate if someone could kindly point to a better way and perhaps put there a few sample code for join and read those datatables.

Thanks very much


PS : Perhaps part of the solution (as in my case shp exists so the join is still required) ? (from jwolter)

SQLiteDataAdapter mySqlAdapter = new SQLiteDataAdapter("SELECT * FROM " + tableName, connString);
System.Data.DataSet myDataSet = new System.Data.DataSet();
DataTable myDataTable = myDataSet.Tables[0];
FeatureSet featureSet = new FeatureSet(FeatureType.Polygon);
featureSet.DataTable = myDataTable;

In this case, if MydDataTable comes from a "select * from the_table" (with or without id), what is the best way to join features and datarows with the id which is in both ? Of course, I would like to use DataRelations if possible.