Select to view content in your preferred language

Add records to SQL from VB.NET

492
0
10-22-2018 09:12 AM
MichaelKohler
Frequent Contributor

I have a requirement to show routes from optimized routing. I have the routing complete and working and now I want to add the route to a map. I added to stops to maps by using the rest add feature call to the server. No problem with 30+ stops. The routes have hundreds of segments in the returned path. I need to show the direction of the paths with arrows at the end. I'm not going to write hundreds of segments to a rest endpoint for a couple dozen routes. I want to add the segments to a SQL database. I've been trying everything and I can add, update and delete as expected but when I try to calculate the SHAPE I get the following error that I can't find anything about.

The UPDATE statement conflicted with the CHECK constraint "g90_ck". The conflict occurred in database "PSLGIS2", table "dbo.BLDG_RTE_STOPS", column 'SHAPE'.‍‍

The sql statement I am sending is 

INSERT INTO BLDG_RTE_STOPS (objectid, inspID, stopOrder,inputOrder, address, x, y, SHAPE) VALUES(3,208,1,2,'123 sw psl blvd',-8943761.976904802,3157847.4254109007,geometry::STPointFromText('POINT(-8943761.97 3157847.42)',3587))‍‍

I can add the attributes and create a new record without issue. I try to run an UPDATE bldg_rte_stops SET SHAPE = and I still get the error.

The feature class is versioned with move edits to base.

SQL 2016 on 2012 windows server

Desktop 10.6

Server 10.5

Edit:

+========================----------------------=================+

I wasn't able to resolve the direct creation of a single feature with a single input statement. If I chunked it up into an insert and add the stop info like address, inspection id's, etc and then call Update, it works. 

objectid is obtained from a single call to SELECT MAX(OBJECTID) and incremented as needed.

INSERT INTO BLDG_RTE_STOPS (objectid, x, y) VALUES(5,-8941512.462, 3156974.749)


update BLDG_RTE_STOPS set SHAPE = geometry::Point([x],[y],3857) where OBJECTID=5
Tags (1)
0 Kudos
0 Replies