I have a spatial model definition which used to be working with SQL Server 2008 but not with 2012 anymore.
I don't know why but I can't get it working...
model.Location = DbGeography.Parse("POINT(" + model.Latitude + " " + model.Longitude + ")");
I am getting this exception:
System.Reflection.TargetInvocationException was unhandled by user code
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Data.SqlClient.SqlSpatialServices.GeographyFromText(String geographyText)
at System.Data.Spatial.DbGeography.Parse(String geographyText)
at b.Helpers.Repository.saveFoursquareMarkers(List1 fs) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\b\Helpers\Repository.cs:line 182
2 parameters)
at b.Controllers.KayController.GetMarkers(String lat, String lng, String type, Double dist, String today, String google) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\b\Controllers\KayController.cs:line 29
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters)
2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass42.b_41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c_DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _)
1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass37.<>c_DisplayClass39.b_33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass4f.b_49()InnerException: System.FormatException
HResult=-2146233033
Message=24141: A number is expected at position 21 of the input. The input has ,905651030368.
Source=Microsoft.SqlServer.Types
StackTrace:
at Microsoft.SqlServer.Types.OpenGisWktReader.RecognizeDouble()
at Microsoft.SqlServer.Types.OpenGisWktReader.ParsePointText(Boolean parseParentheses)
at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.STGeomFromText(SqlChars geometryTaggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
Any help ?