TCPSocket Commands out of sync

Hi all
XOJO

I have a server application and a client application and I make communications between both using TCPsocket.
I can make several queries and consecutively everything works perfectly
The code is the following:
In PushButton in the Action event

Dim sql As string
sql = "SELECT codlugar,nomlugar FROM lugares WHERE codlugar='"+Self.txtCodlugar.text+"'"
Socket.Write sql + ChrB(26)

In Another PushButton in the Action event

Dim sql As string
sql = "SELECT codbanco,nombanco FROM bancos WHERE codbanco='"+Self.txtCodBanco.text+"'"
Socket.Write sql + ChrB(26)

I can insert several records and consecutively and everything works perfectly
In Another PushButton in the Action event

Dim sql,codlugar,nomlugar,zona As string
codlugar="036"
nomlugar="URB. LOS CLAVELES"
zona="R5"
sql="INSERT Lugares(codlugar,nomlugar,zona) VALUES ('"+codlugar+"','"+nomlugar+"','"+zona+ "')"
Socket.Write sql + ChrB(26)

After the insertion, I can make other consultations and everything works fine

By using a stored procedure that returns a value for the entry of a new record, it registers it very well in the database and returns a value
In PushButton in the Action event
The code is the following:

Dim sql,nomlugar,zona,codlugar As string
codlugar="036"
nomlugar="URB. NUEVO HORIZONTE"
zona="R5"
sql="CALL bdadmbrea.lugaresins('"+nomlugar+"','"+zona+"',@'"+codlugar+"')"
Socket.Write sql + ChrB(26)

When I try to make other queries, after having made an insert using a stored procedure, I get the following error:

Commands out of sync; you can not run this command now

Any comment will be very appreciated to help me solve the error:

Cordially,

Raul Juarez Pulache

The error is not about TCPSocket, but rather an error from your database server.

https://stackoverflow.com/questions/614671/commands-out-of-sync-you-cant-run-this-command-now#614741

Infinite Thanks
Greg O’Lone

Exactly the error was originated by the database server
In Mysql change The stored procedure by a function

Dim sql,nomlugar,zona As string
nomlugar="URB. NUEVO HORIZONTE"
zona="R5"
sql = "SELECT funclugaresins('"+nomlugar+"','"+zona+"') As pcodlugar"
Socket.Write sql + ChrB(26)

The function only returns me the value I need and everything works correctly,

Many blessings

Raul Juarez Pulache