# Adding new line or editing existing line on SQL table

**URL:** <https://mapwindow.discourse.group/t/adding-new-line-or-editing-existing-line-on-sql-table/1009>\
**Category:** Uncategorized\
**Created:** [May 27, 2021, 8:57am UTC](https://mapwindow.discourse.group/t/adding-new-line-or-editing-existing-line-on-sql-table/1009 "2021-05-27T08:57:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![colleen](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@colleen](https://mapwindow.discourse.group/u/colleen)\
**Post date:** [May 27, 2021, 8:57am UTC](https://mapwindow.discourse.group/t/adding-new-line-or-editing-existing-line-on-sql-table/1009/1 "2021-05-27T08:57:30Z")

</div>

Hi

I wonder if someone can tell me if I am on the right track.

I need to create new lines or edit existing lines that are stored in a geometry field on an sql database.

To create the new line I thought I could build up a new shape and then use SerializeToString and then use this to write to the sql database. It seems to have the x/y coords of each point in the string.Not sure if I need to extract these or if can be used as is. Using something similar to this  
INSERT INTO SpatialTable (GeomCol1)  
VALUES (geometry::STGeomFromText(‘LINESTRING (100 100, 20 180, 180 180)’, 0));

When creating a new line (a section of the road) I would also like to base it on the road lines. I assume for this I could get all the points on the road (using the SerializeToString) and build up the line from the point closest to where I had clicked for the start of the line and move along the line until I reach the end point that has been clicked

To edit the line I might add onto the end of the existing line or reduce the length of the line.

I assume the editing of shapes and saving them can only be done on shape files so in order to update to an sql table I would have to do the above. Is this correct?

Regards

Colleen Crawford

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 24, 2022, 3:33pm UTC](https://mapwindow.discourse.group/t/adding-new-line-or-editing-existing-line-on-sql-table/1009/2 "2022-01-24T15:33:31Z")

</div>

Hi Colleen,

Sorry for the very late reply.  
Did you already looked at [AxMap.AddLayerFromDatabase()](https://mapwindow.org/documentation/mapwingis4.9/group __map__ layer__management.html#ga3672fae9774e0bbb917ab23e13855ebe)?  
It should give you access to the underlying shapefile-objects and edit them.
