Android Question How do I resolve this problem?

dhernandez

Active Member
Licensed User
Longtime User
I am trying to update two tables at the same time .. But with a JonDone not know how to do, so I took another method and made the definition of another table to update, but I get error.

//First HttpJob(First Table)
B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        ToastMessageShow("No es posible la conexión",True)
    Else 
        If Job.JobName = "DBRequest" Then
              If SQL1.IsInitialized=False Then SQL1.Initialize(ruta, "am14dbishe.db", True, "Asdfg1234",ruta)
                  SQL1.ExecNonQuery("DELETE FROM t_extintor_titulo")
                Dim Result As DBResult = ReqManagerList.HandleJob(Job)
                SQL1.BeginTransaction                       
                  For Each records() As Object In Result.Rows           
                       SQL1.ExecNonQuery2("INSERT INTO t_extintor_titulo VALUES (?,?,?,?,?,?,?)",Array As Object(records(0),records(1),records(2),records(3),records(4),records(5),records(6)))
                Next
                 SQL1.TransactionSuccessful
                 SQL1.EndTransaction   
            End If
        End If
End Sub

Second HttpJob
B4X:
Sub TrabajoTerminado(Trabajo As HttpJob)
    If Trabajo.Success = False Then
        ToastMessageShow("No se puede realizar la conexion", True)
    Else
        If Trabajo.JobName = "DBRequest" Then
            SQL1.ExecNonQuery("DELETE FROM t_extintor_det")
            Dim Resultado As DBResult = administrarlista.HandleJob(Trabajo)
                SQL1.BeginTransaction
                For Each Registros() As Object In Resultado.Rows
                    SQL1.ExecNonQuery2("INSERT INTO t_extintor_det VALUES (?,?,?,?,?)", Array As Object(Registros(0),Registros(1),Registros(2),Registros(3),Registros(4)))
                Next
                SQL1.TransactionSuccessful
                 SQL1.EndTransaction   
        End If
    End If
End Sub

I have no idea how to update two tables with HttpJob with a table no problem, but I do have problems with two.

Someone who can help me?
 

DonManfred

Expert
Licensed User
Longtime User
just assign a different name for each jobname
Using dbrequestmanager the Jobname is always "DBRequest"!

When defining the request you can set a Tag for it
B4X:
reqManager.ExecuteQuery(cmd, 0, "cat 1")
and then in JobDone you do
B4X:
Dim result As DBResult = reqManager.HandleJob(Job)
If result.Tag = "cat 1" Then 'query tag
  ' your code here
end if
 
Upvote 0
Top