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

'invalid column name' error accessing MS-SQL 2005

Topics: General Topics
Nov 18, 2006 at 4:17 PM

I have installed SQL Server 2005 Express plus MsSqlSpatial, then created a new table using CREATE TABLE and after run a SELECTADDGEOMETRY to create thegeom column at this polygon table. After running this command I saw some new fieds at my table: thegeom, thegeomEnvelopeMinX, thegeomEnvelopeMinY, thegeomEnvelopeMaxX and thegeomEnvelopeMaxY.

Now I'd like to load spatial table from MsSQLSpatial but I got only the 4 error messages when running .getMap() method:
-invalid column name Envelope_MinX
-invalid column name Envelope_MinY
-invalid column name Envelope_MaxX
-invalid column name Envelope_MaxY

Here's the code I'm trying to run:
SharpMap.Map myMap = new SharpMap.Map(new Size(450, 300));
myMap.MinimumZoom = 100;
myMap.BackColor = Color.White;
myMap.Zoom = 120;
myMap.Size = new System.Drawing.Size(450, 300);
SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer("msql1");
string ConnStr = "Data Source=mssqlx2005;Initial Catalog=my_db;User Id=root;Password=*****;";
myLayer.DataSource = new SharpMap.Data.Providers.MsSql(ConnStr,"myPolyTable","the_geom","gid" );

pictureBox1.Image = myMap.GetMap();
Nov 18, 2006 at 6:05 PM
This might be a little confusing but there are actually two MsSql providers. You are using the "Original" one which uses an approach described here:
The MsSqlSpatial grew from this approach, but extended it far beyond that, including full topology rules, reprojections, geoprocessing etc. Since this was released after v0.9, you should grab the latest SharpMap sources and use the MsSqlSpatial provider instead.