Problem to insert into the database - SQL

1

Follow the code:

Update command works:

int noOfRowUpdated = ctx.Database.ExecuteSqlCommand("Update Mapa set Geo = geography::Point(47.65100, -122.34900, 4326) where Id= 1");

What does not work is insert command:

int noOfRowInserted = ctx.Database.ExecuteSqlCommand("INSERT into Mapa(Geo) values('geography::Point(47.65100, -122.34900, 4326)')");

I get this error:

  

The .NET Framework error occurred during execution of user-defined   routine or aggregate "geography": System.FormatException: 24114: o   geography :: Point (47) in the WKT (well-known text) entry is not   valid. Valid labels are: POINT, LINESTRING, POLYGON, MULTIPOINT,   MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING,   COMPOUNDCURVE, CURVEPOLYGON, and FULLGLOBE (Data Type Only   geography). System.FormatException: in   Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel (String input) in   Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText (OpenGisType   type) in   Microsoft.SqlServer.Types.WellKnownTextReader.Read (OpenGisType type,   Int32 srid) in   Microsoft.SqlServer.Types.SqlGeography.ParseText (OpenGisType type,   SqlChars taggedText, Int32 srid) in   Microsoft.SqlServer.Types.SqlGeography.GeographyFromText (OpenGisType   type, SqlChars taggedText, Int32 srid) in   Microsoft.SqlServer.Types.SqlGeography.Parse (SqlString s). The   statement has been terminated.

    
asked by anonymous 07.01.2017 / 04:55

1 answer

3

Single quotation marks must start before% w / o% not before% w / o%. If not, try removing them.

How to in this example from Microsoft:

.
.
.

INSERT INTO SpatialTable (GeogCol1)  
VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));

.
.
.

Have you seen it ?! No quotation marks surrounding the geography keyword.

    
07.01.2017 / 05:06