Problem adding layer from SQL Server Express 2012...

Topics: Data Access, SharpMap v2.0, WinForms Controls
Aug 14, 2013 at 5:57 PM
Edited Aug 14, 2013 at 9:14 PM
Hi everybody,

I'm having problems adding a layer to Map control in my WinForm, using this code in a new c# project:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GESEN_Desktop
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("CIRC");
            vlay.DataSource = new SharpMap.Data.Providers.SqlServer2008(@"Data Source=C-00000021;Initial Catalog=HURDAT;Integrated Security=True", "CIRC", "OBJECTID");
            
            mapBox1.Map.Layers.Add(vlay);
            mapBox1.Map.ZoomToExtents();
            mapBox1.Refresh();
        }
    }
}
Error:
Excepción del tipo 'System.Data.SqlClient.SqlException' en System.Data.dll
Excepción del tipo 'System.Data.SqlClient.SqlException' en System.Data.dll
.

Printing vlay.DataSource.GetFeatureCount() before adding to map control, gave me 307 features

I'm trying to checkout SharpMap project (https://sharpmap.svn.codeplex.com/svn/trunk) to get a more specific error but in the meanwhile if you can help me would be great!

Download: SharpMap and SharpMap.UI (https://sharpmap.codeplex.com/downloads/get/708032)
Windows 7
Visual Studio 2010 Ultimate
.NET Framework 4.0
Microsoft SQL Server Express (64-bit) 2012


--- Edit
I found this in svn:
The geography datatype does not have the STEnvelope method. If using SQL2012, EnvelopeAggregate provides an alternative
-

...and change my code to:
ds.ExtentsMode = SharpMap.Data.Providers.SqlServer2008ExtentsMode.EnvelopeAggregate;
the previous code create a sql text:
SELECT geography::EnvelopeAggregate(g.SHAPE).STAsText() FROM CIRC g;
..and returns:
CURVEPOLYGON
CURVEPOLYGON (CIRCULARSTRING (-86.5869363109314 21.707295066789264, -94.0386783660673 21.707295066789264, -93.8940916756448 14.784770632927236, -86.731523001353921 14.784770632927236, -86.5869363109314 21.707295066789264))
It throws and parse error: Unknown type: CURVEPOLYGON

Any help would be great! :D
Coordinator
Aug 15, 2013 at 5:44 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.