locked
Sending spatial data to C# application: RRS feed

  • Question

  • 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
    Thursday, January 12, 2012 10:31 AM

All replies

  • 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
    Thursday, January 12, 2012 12:03 PM