Buenas People,
a ver si alguien me puede dar la respuesta,
Me hecho una app para leer una tabla en mysql web, cada 1s se va actualizando por si hay
nuevos datos en la SQL, el problema viene cuando desde la misma app inserto nuevos datos
ya que me tira mensaje de error, si voy directamente a MySQL y ahi añado nuevos datos
los veo desde mi app ya que se actualiza cada 1s, pero si los añado desde mi app no me
deja... os pongo el código a ver que opináis:
El Error me lo da aquí:
countries = parser.NextArray
CODIGO:
Sub Process_Globals
Dim hc As HttpClient
Dim paises, poblacion As Int
paises = 1 ' Es la tarea 1
Dim WELL_INSERT As Int :WELL_INSERT = 1
Dim v As Int
End Sub
Sub Globals
Dim timer1 As Timer
Dim borraID, ID, x, y As String
Type Renglones (Renglon1 As String, Renglon2 As String)
Dim Label1 As Label
Dim ListView1 As ListView
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("p")
Buscar_lista_de_paises
Dim p As Phone
If p.SdkVersion >= 9 Then
Dim r As Reflector
r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
r.Target = r.RunMethod("permitAll")
r.Target = r.RunMethod("build")
r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
timer1.Initialize("Timer1", 1500) ' 1000 = 1 second
timer1.Enabled = True
Buscar_lista_de_paises
End Sub
Sub Buscar_lista_de_paises
'ProgressDialogShow("Buscando SQL.")
Dim req As HttpRequest
Dim Query As String
Query="SELECT nombre, poblacion FROM paises ORDER BY ID"
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req,1) '''''''' En ResponseSuccess hará el Case de paises
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
'databaseconnect.php is the name of the php file listed in the post
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, tarea As Int)
Dim res As String
res=""
res = Response.GetString("UTF8")
Label1.Text=res
Log("Respuesta del servidor: " & res)
'res = [{"nombre":"Argentina","id":"AR"},.... hasta ....,{"nombre":"Venezuela","id":"VE"}]
Dim parser As JSONParser
parser.Initialize(res)
Select tarea
' ************* PAISES *****************
Case paises
' Añade paises la ListView1
ListView1.clear
Label1.Text=""
Dim countries As List
countries.Initialize
countries = parser.NextArray
For i = 0 To countries.Size - 1
Dim m As Map
m = countries.Get(i)
Dim Renglon As Renglones
Renglon.Renglon1 = m.Get("ID") ' ES
Renglon.Renglon2 = m.Get("nombre") ' España
ListView1.AddSingleLine(Renglon.Renglon2)
'Label1.Text= Label1.Text & " " & Renglon.Renglon2
Next
'ProgressDialogHide
countries.Clear
End Select
Response.Release
End Sub
Sub timer1_tick
Buscar_lista_de_paises
End Sub
Sub Button2_Click
'guardadat=1
Dim req As HttpRequest
Dim Query As String
'ID = "77d14"
x = "Prueba2"
y = "p2"
Query="INSERT INTO paises (nombre, poblacion) VALUES ('" & x & "','" & y & "')"
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, 1)
Buscar_lista_de_paises
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, tarea As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
'ProgressDialogHide
End Sub
Sub Button3_Click
ExecuteRemoteQuery("INSERT INTO paises (nombre, poblacion) " _
& "VALUES ('jiji','jojo')",WELL_INSERT)
Buscar_lista_de_paises
End Sub
Muchas GRACIAS!!!!
a ver si alguien me puede dar la respuesta,
Me hecho una app para leer una tabla en mysql web, cada 1s se va actualizando por si hay
nuevos datos en la SQL, el problema viene cuando desde la misma app inserto nuevos datos
ya que me tira mensaje de error, si voy directamente a MySQL y ahi añado nuevos datos
los veo desde mi app ya que se actualiza cada 1s, pero si los añado desde mi app no me
deja... os pongo el código a ver que opináis:
El Error me lo da aquí:
countries = parser.NextArray
CODIGO:
Sub Process_Globals
Dim hc As HttpClient
Dim paises, poblacion As Int
paises = 1 ' Es la tarea 1
Dim WELL_INSERT As Int :WELL_INSERT = 1
Dim v As Int
End Sub
Sub Globals
Dim timer1 As Timer
Dim borraID, ID, x, y As String
Type Renglones (Renglon1 As String, Renglon2 As String)
Dim Label1 As Label
Dim ListView1 As ListView
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("p")
Buscar_lista_de_paises
Dim p As Phone
If p.SdkVersion >= 9 Then
Dim r As Reflector
r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
r.Target = r.RunMethod("permitAll")
r.Target = r.RunMethod("build")
r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
timer1.Initialize("Timer1", 1500) ' 1000 = 1 second
timer1.Enabled = True
Buscar_lista_de_paises
End Sub
Sub Buscar_lista_de_paises
'ProgressDialogShow("Buscando SQL.")
Dim req As HttpRequest
Dim Query As String
Query="SELECT nombre, poblacion FROM paises ORDER BY ID"
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req,1) '''''''' En ResponseSuccess hará el Case de paises
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
'databaseconnect.php is the name of the php file listed in the post
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, tarea As Int)
Dim res As String
res=""
res = Response.GetString("UTF8")
Label1.Text=res
Log("Respuesta del servidor: " & res)
'res = [{"nombre":"Argentina","id":"AR"},.... hasta ....,{"nombre":"Venezuela","id":"VE"}]
Dim parser As JSONParser
parser.Initialize(res)
Select tarea
' ************* PAISES *****************
Case paises
' Añade paises la ListView1
ListView1.clear
Label1.Text=""
Dim countries As List
countries.Initialize
countries = parser.NextArray
For i = 0 To countries.Size - 1
Dim m As Map
m = countries.Get(i)
Dim Renglon As Renglones
Renglon.Renglon1 = m.Get("ID") ' ES
Renglon.Renglon2 = m.Get("nombre") ' España
ListView1.AddSingleLine(Renglon.Renglon2)
'Label1.Text= Label1.Text & " " & Renglon.Renglon2
Next
'ProgressDialogHide
countries.Clear
End Select
Response.Release
End Sub
Sub timer1_tick
Buscar_lista_de_paises
End Sub
Sub Button2_Click
'guardadat=1
Dim req As HttpRequest
Dim Query As String
'ID = "77d14"
x = "Prueba2"
y = "p2"
Query="INSERT INTO paises (nombre, poblacion) VALUES ('" & x & "','" & y & "')"
req.InitializePost2("http://blablabla/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, 1)
Buscar_lista_de_paises
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, tarea As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
'ProgressDialogHide
End Sub
Sub Button3_Click
ExecuteRemoteQuery("INSERT INTO paises (nombre, poblacion) " _
& "VALUES ('jiji','jojo')",WELL_INSERT)
Buscar_lista_de_paises
End Sub
Muchas GRACIAS!!!!
Last edited: