Hello,
If someone could help me I would appreciate.
I have dbutills in this project where I added the UpdateRecordMap code I have found here in the forum.
When I run the code below, I get a Java error.
I get the same error either witn UpdateRecord2 or updateRecordMap.
What am I doing wrong ?
I have made a few experiences, but always get the same result.
Thanks in advance for your help.
If someone could help me I would appreciate.
I have dbutills in this project where I added the UpdateRecordMap code I have found here in the forum.
When I run the code below, I get a Java error.
I get the same error either witn UpdateRecord2 or updateRecordMap.
What am I doing wrong ?
I have made a few experiences, but always get the same result.
Thanks in advance for your help.
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim httpC As HttpClient 'the Connection client
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim sql1 As SQL
Dim hoje As String
Dim cursor1 As Cursor
Dim id_aluno As String
Dim id_aluno_temp As String
Dim nome As String
Dim apelido As String
Dim telf1 As String
Dim LA As String
Dim categoria As String
Dim id_no_server As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
httpC.Initialize("httpC")
End If
If sql1.IsInitialized = False Then
sql1.Initialize(File.DirDefaultExternal,"gesdriver_a.sql", False)
End If
DateTime.DateFormat="yyyy-MM-dd"
hoje=(DateTime.date(DateTime.Now))
trata_alunos
End Sub
Sub trata_alunos
Dim Query As String
cursor1 = sql1.ExecQuery("SELECT id_no_server,id_aluno FROM agenda_local WHERE data='"&hoje&"'")
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
id_aluno=cursor1.GetString("id_aluno")
id_no_server=cursor1.GetString("id_no_server")
ToastMessageShow ("aluno :"&id_aluno,False) 'DEBUG
' **************************************************
' Getting data from server
' **************************************************
ProgressDialogShow("A receber dados de alunos")
executa_queryRemoto("SELECT nome,apelido,telf1,LA,categoria FROM alunos where id_aluno='" &id_aluno&"'", 1) ' o query vai pedir o aluno, LEVA O TASKID 1
' executa_queryRemoto("SELECT * FROM alunos where id_aluno='" &id_aluno&"'", 1)
ToastMessageShow ("ENCONTREI O ALUNO : "&nome,False)
Next
cursor1.Close
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub executa_queryRemoto(Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://www.dev.gesdriver.com/service1.php", Query.GetBytes("UTF8"))
httpC.Execute(req, TaskId)
End Sub
Sub httpC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Msgbox("Erro ao ligar ao servidor"&CRLF&CRLF&Reason,"Erro("&StatusCode&")")
ProgressDialogHide
End Sub
Sub httpC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
ProgressDialogShow("A Actualizar alunos :")
Dim res As String
res = Response.GetString("UTF8")
'Label1.Text=res
Dim parser As JSONParser
parser.Initialize(res)
Dim alunos As List
alunos = parser.NextArray
For i = 0 To alunos.Size - 1
Dim m As Map
m = alunos.Get(i)
id_aluno_temp=m.Get("id_aluno")
nome=m.Get("nome")
apelido=m.Get("apelido")
'morada=m.Get("Morada")
'localidade=m.Get("localidade")
'cod_postal=m.Get("cod_postal")
'ext_cod_postal=m.Get("ext_cod_postal")
telf1=m.Get("telf1")
'telf2=m.Get("telf2")
'email=m.Get("email")
'nif=m.Get("nif")
'bi=m.Get("bi")
'nascimento=m.Get("nasimento")
LA=m.Get("LA")
categoria=m.Get("categoria")
' ********************************************************************************************
' Storing the line in local DB
' *********************************************************************************************
Dim novo_valor_campo As Map
novo_valor_campo.Initialize
novo_valor_campo.Put("nome", nome)
novo_valor_campo.Put("apelido", apelido)
novo_valor_campo.Put("telf1", telf1)
novo_valor_campo.Put("LA", LA)
novo_valor_campo.Put("categoria", categoria)
Dim campo_a_actualizar As Map
campo_a_actualizar.Initialize
campo_a_actualizar.Put ("id_no_server", id_no_server)
DButils.UpdateRecordMap (sql1,"agenda_local",novo_valor_campo,campo_a_actualizar)
Next
ProgressDialogHide
Response.Release
End Sub
Last edited: