Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Locked Sending spatial data to C# application:

  • Thursday, January 12, 2012 10:31 AM
     
     
    Hi, Can I send spatial data to my application (which is in C#.NET)? If so, how can I achieve that? For example I've the following code in SQL: SET @geom = geometry::STGeomFromText('POLYGON((3 -6, 8 -3, 8 2, 2 5, -2 0, 3 -6))', 4326) What happens if I send @geom to C# application? Thanks, Santosh

All Replies

  • Thursday, January 12, 2012 12:03 PM
     
     Proposed Has Code

    Spatial functionality in SQL Server is provided by two DLL libraries - Microsoft.SqlServer.Types.dll (managed) and SqlServerSpatial.dll (unmanaged). Import Microsoft.SqlServer.Types.dll into your C# project and you can use the SqlGeography/SqlGeometry type in exactly the same way as the geography/geometry type within SQL Server. So your example above would become i.e.

    SqlGeometry geom = SqlGeometry.STGeomFromText(new SqlChars("POLYGON((3 -6, 8 -3, 8 2, 2 5, -2 0, 3 -6))"), 4326);
    

     


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Proposed As Answer by Horizon_Net Thursday, January 12, 2012 1:58 PM
    •