title: Creating a sqlGeography LINESTRING using .NET
body: <p>I am building an application that parses a variety of external map file formats (i.e. ShapeFiles, MapPoint, KML, etc.) and stores the shapes in a centralized database that will be used for a central mapping / reporting base. I have a routine that now has a line represented by an abstract array of points, and I'm attempting to turn that into a sqlGeography object that will be store in my database (SQL2012 Express at the moment).</p>
  
  <p>Here's an example of my LINESTRING statement (stored in a string strGeo):</p>
  
  <pre><code>    LINESTRING(41.942587758675 -85.636084221926,41.9425261573997 -85.6360833224383,41.9423450573927 -85.6360807217602,41.9423035553449 -85.6360801225198,41.9421639573891 -85.6360781210972,41.9421098574371 -85.6360773225739,41.9420307561342 -85.6360762213003)
  </code></pre>
  
  <p>I then perform this operation on that string (VB.NET)</p>
  
  <pre><code>    Dim strSql As New SqlChars(New SqlString(strGeo))
      Dim geo As SqlGeography = SqlGeography.STLineFromText(strSql, 4326)
  </code></pre>
  
  <p>I've added appropriate references to Microsoft.SqlServer.Types from the SQL Server 2012 Feature pack, but when my debugger hits the SqlGeography line, I get this:</p>
  
  <pre><code>    System.DllNotFoundException: Unable to load DLL 'SqlServerSpatial110.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
      at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoMarshalData g, Double eccentricity, Boolean forceKatmai, Boolean&amp; result, Boolean&amp; isSmallerThanAHemisphere)
      at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoData&amp; g, Double eccentricity, Boolean forceKatmai)
      at Microsoft.SqlServer.Types.SqlGeography.IsValidExpensive(Boolean forceKatmai)
      at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid)
      at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
      at Microsoft.SqlServer.Types.SqlGeography.STLineFromText(SqlChars lineStringTaggedText, Int32 srid)
      at ShpFileProcessor.Module1.ProcessFile(FileInfo fil) in C:\Users\Chet Cromer\documents\visual studio 2010\Projects\NorthernLights\ShpFileProcessor\ShpFileProcessor\Module1.vb:line 180
  </code></pre>
  
  <p>I cannot find SqlServerSpatial110.dll anywhere on my computer. I have SQL Express 2012 installed, and can find SqlerverSpatial.dll in both SYSTEM32 and SYSWOW64, but VS will not let me register either of those files.</p>
  
  <p>I've noticed that if I use TWO parentheses in my LINESTRING like this I get a different error:</p>
  
  <pre><code>    LINESTRING((41.942587758675 -85.636084221926,41.9425261573997 -85.6360833224383,41.9423450573927 -85.6360807217602,41.9423035553449 -85.6360801225198,41.9421639573891 -85.6360781210972,41.9421098574371 -85.6360773225739,41.9420307561342 -85.6360762213003))
  
      System.FormatException: 24141: A number is expected at position 27 of the input. The input has (41.942587758675.
      at Microsoft.SqlServer.Types.WellKnownTextReader.RecognizeDouble()
      at Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText()
      at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
      at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
      at Microsoft.SqlServer.Types.SqlGeography.ParseText(OpenGisType type, SqlChars taggedText, Int32 srid)
      at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
      at Microsoft.SqlServer.Types.SqlGeography.STLineFromText(SqlChars lineStringTaggedText, Int32 srid)
      at ShpFileProcessor.Module1.ProcessFile(FileInfo fil) in C:\Users\Chet Cromer\documents\visual studio 2010\Projects\NorthernLights\ShpFileProcessor\ShpFileProcessor\Module1.vb:line 180
  </code></pre>
  
  <p>(Before you count characters, position 27 is the space between the first lat/lon combo)</p>
  
  <p>I expect that my first string format is the correct format, but at this point I'm not sure, and I'm not sure what to do with the SqlServerSpatial110.dll issue.</p>
  
  <p>Anybody been down this road? Am I missing something?</p>