简体   繁体   中英

Where is the syntax error in this sql query?

I'm working with PostGIS and spatial data types from VB, and I have this insert query, which I use to save the data of the marker that is placed on the map (I want to save the latitude and longitude of the marker placed on the map in the database). I tried to use "double" and "decimal", but this is the most "professional" way to save coordinates I think..

 $"insert into personas values ('" & idpers & "','" & txtNombre.Text & "','" & txtApe.Text & "','" & txtTel.Text & "','" & txtDire.Text & "','" & cboxZona.SelectedItem & "',ST_GeomFromText('POINT('" & txtLatBD.Text & "' '" & txtLngBD.Text & "')'))" 

I think I'm missing a symbol somewhere, but I don't see where. When I insert the same data from the console, it works fine..

@Plutonix is correct - but in response to your syntax error question, you appear to have extra quotes: example:

ST_GeomFromText('POINT(-70.060544 40.28707)');

yours (numbers replacing variables):

ST_GeomFromText('POINT('-70.060544' '40.28707')')

yours (fixed with variables):

ST_GeomFromText('POINT(" & txtLatBD.Text & " " & txtLngBD.Text & ")')

Reference for the Constructor: http://www.postgis.org/docs/ST_GeomFromText.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM