I am trying to insert a Sqlgeography column from latitude, longitude points to SQL server 2016 but I am getting
Exception thrown: 'System.FormatException' in Microsoft.SqlServer.Types.dll
I have already installed the Microsoft System CLR Types for SQL Server 2016 on the machine. What is the correct approach to resolve this issue.
SqlCommand addpoint = new SqlCommand("INSERT INTO " + Helper.TABLE_ALLINDEXPOINTS + "values (@id, @latitude, @longitude, @streetname, @longlat", sqlConnection);
addpoint.Parameters.AddWithValue("@id", id);
addpoint.Parameters.AddWithValue("@latitude",Convert.ToDouble(snappedPoints[j]["latitude"]));
addpoint.Parameters.AddWithValue("@longitude",Convert.ToDouble(snappedPoints[j]["longitude"]));
addpoint.Parameters.AddWithValue("@streetname", snappedPoints[j]["name"].ToString());
addpoint.Parameters.AddWithValue("@longlat", SqlGeography.STGeomFromText(new SqlChars(string.Format("POINT({0} {1})", snappedPoints[j]["latitude"], snappedPoints[j]["longitude"])), Helper.SRID));
addpoint.ExecuteNonQuery();
Error:
'ConsoleApp2.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\ssindhu\source\repos\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.exe'. Symbols loaded. 'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Users\ssindhu\source\repos\ConsoleApp2\ConsoleApp2\bin\Debug\Newtonsoft.Json.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Types\14.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll'. Cannot find or open the PDB file.
'ConsoleApp2.exe' (CLR v4.0.30319: ConsoleApp2.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll'. Cannot find or open the PDB file.
This is the table schema:
create table all_index_points
(
id varchar(450) not null primary key,
latitude float,
longitude float,
streetname nvarchar(max),
longlat geography
);
Values
word? like" values
not"values
– maulik kansara