Sub update_location (imei As String , lattitude As String , longitude As String)
Try
Dim rs As ResultSet
Dim sql_que_data As String = $"Select c.ID As CASO from GMT.Dispositivos d inner join GMT.Asociacion_Dispositivos ad on ad.PanicbuttonID = d.ID inner join GMT.Perfiles p on p.DeviceID = ad.ShacklesID inner join GMT.Casos c on c.ProfileID = p.ID where d.imei = ${imei}"$
Log(sql_que_data)
rs = Main.sql1.ExecQuery(sql_que_data)
Dim Buffer() As Byte
Dim bc As ByteConverter
Do While rs.NextRow
Buffer = rs.GetBlob("CASO")
If Buffer <> Null And Buffer.Length > 0 Then
'Dim pp As String = bc.HexFromBytes(Buffer)
Dim pp As String = $"0x${bc.HexFromBytes(Buffer)}"$ 'Hex string for MySQL.
Log(bc.HexFromBytes(Buffer))
Log(pp) 'Should log a proper hex string for MySQL with 0x pre-pended
Log(Buffer.Length)
Try
Dim sql_update As String = "UPDATE Ubicacion set lat = ?,lon=? where CaseID = ?"
'Log($"UPDATE Ubicacion set lat='${lattitude}', lon='${longitude}' WHERE CaseID = '${bc.HexToBytes(pp)}'"$)
Log($"UPDATE Ubicacion set lat='${lattitude}', lon='${longitude}' WHERE CaseID = '${pp}'"$) 'Just pass pp without reconverting to bytes
'Main.SQL1.ExecNonQuery2(sql_update, Array As Object(lattitude, longitude,bc.HexToBytes(pp)))
Main.SQL1.ExecNonQuery2(sql_update, Array As Object(lattitude, longitude, pp)) 'Were just passing the MySQL hex string
'Main.SQL1.ExecNonQuery2(sql_update, Array As Object(lattitude,longitude,Buffer))
Catch
Log(LastException)
Return
End Try
End If
Loop
Catch
Log(LastException)
End Try
End Sub