MsSqlSpatial - Can't figure out how to use?

Topics: SharpMap v0.9 / v1.x, SharpMap v2.0
Oct 16, 2012 at 7:11 AM
Edited Oct 16, 2012 at 7:16 AM

How difficult could this be? I try to use the SharpMap MsSqlSpatial, but keep getting an error I can not figure out. I use full target framework 4.0, I use VS2010 with SQL 2008 Express, added reference to Microsoft.SqlServer.Types, but still same error. If you look at my samples beneath, test1() run successful, but test2() fail! Does anyone have good suggestions or other simple examples?

Regards Jens

    private void test1()
      string connStr = "Data Source=PPCJET1;Database=SharpMapTest;Integrated Security=True;";
      SqlConnection sqlCon = new SqlConnection(connStr);
      string commandString = "SELECT * FROM Krets";
      SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
      SqlDataReader dataReader = sqlCmd.ExecuteReader();
      while (dataReader.Read())
        Console.WriteLine(String.Format("{0} {1}", dataReader["ID"], dataReader["AREA"]));

    private void test2()
      string connStr = "Data Source=PPCJET1;Database=SharpMapTest;Integrated Security=True;";
      SharpMap.Data.Providers.MsSqlSpatial dataSource = new SharpMap.Data.Providers.MsSqlSpatial(connStr, "Krets", "geom", "ID");
      // datasource throw an execption --> Columns = 'dataSource.Columns' threw an exception of type 'System.NotImplementedException'
Oct 16, 2012 at 7:29 AM


please use the SharpMap.Data.Providers.SqlServer2008  provider


Oct 17, 2012 at 6:46 AM

Thanks! It work!