This project has moved. For the latest updates, please go here.

Shapefile to sql server 2005

Topics: Data Access, SharpMap v0.9 / v1.x
Jun 17, 2010 at 5:56 PM

I have a sql server 2005 database that a few other applications are currently pulling polygon data from to build carrier routes.  I was wondering if there's a way to load a shape file with SharpMap and then loop through all of the carrier routes in my shape file and insert them into my database?  Using some of the documentation I loaded one of the shape files into a VectorLayer, I'm just not sure if there is a way for me to loop through that data.


Jun 18, 2010 at 9:07 AM

Hi Gauzzastrip, Shapefiles have contiguous integer ids starting at 1 so you can loop through the shapefile calling provider.GetGeometryByID(id) or provider.GetFeature(id)  if you need the attribute data too. So start with index 1 and finish at provider.GetFeatureCount().

Geometry has AsBinary() and AsText() which you can save to your Sql 2005 db - you may also be interested in Ms Sql Spatial (  which gives spatial functionality to sql 2005.


hth jd