2

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
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
2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass42.b_41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c_DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
1.End()
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 ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Görkem Öğüt
  • 1,761
  • 3
  • 18
  • 29

2 Answers2

1

It was really not understandable with this error but the problem was the localization of my computer.

It was expecting a dot (.) rather than coma (,) as my decimal symbol. I've just set it from Start>Control Panel>Region and Language>Additional Settings and voila. It is working now.

Thank you for your helps.

Görkem Öğüt
  • 1,761
  • 3
  • 18
  • 29
  • I also removed my GIS software with SQL 2008. Usually this GIS software was changing the dot with coma automatically but this time it was not possible for me to realize that. Sorry, if I made trouble for you also. – Görkem Öğüt Apr 11 '12 at 07:02
0

Unistall the CTP and install .NET Framework 4.5 beta. If you still have the problem update the thread.

Pawel
  • 31,342
  • 4
  • 73
  • 104