ZoomToExtents Exception

Topics: Data Access
May 2, 2007 at 2:35 AM
I'm trying to connect to MsSQLSpatial installed on my SQL Server 2005 machine to grab a table that I imported from a shapefile, but when I run my application it bombs on the ZoomToExtents saying that it is an invalid cast. My columns are of the data that FLOAT, so there should be no problem converting to Double. I cannot find any examples of hooking up SharpMap with MsSQLSpatial so I had to go with the PostGIS example. My code is as follows:

String spatialConnect = "Data Source=_;Initial Catalog=FireSiteSpatial;" +
"Persist Security Info=True;User ID=;Password=";
SharpMap.Map map = new SharpMap.Map(size);
SharpMap.Data.Providers.MsSql msSQL = new SharpMap.Data.Providers.MsSql(
spatialConnect, "AshleyTutorial", "fgeometrycolumn", "oid");
SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("AshleyTutorial");
layCountries.DataSource = msSQL;

layCountries.Style.Line = new Pen(Color.Red);
layCountries.Style.Outline = System.Drawing.Pens.Red;
map.ZoomToExtents();//EXCEPTION: invalid cast

Thanks in advance,