Android Question Looping through table and insert records

Makumbi

Well-Known Member
Licensed User
Please help my code is duplicating records
This is the firt table that is supposed to be checked then after we insert records in table 2 base on table one
B4X:
[{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]

This is the jason data with marks
B4X:
[{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]

This is the code below which duplicates records during insertion
B4X:
Dim kt As String
    kt=1
    Dim jbr As HttpJob
    jbr.Initialize("", Me)
    jbr.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBStartedacademic.ashx?customerid=" & kt)
    'jb.GetRequest.Timeout=30000
    jbr.Release
    cursor1 = Starter.SQL1.ExecQuery("SELECT ID,Account FROM Allacounts")
    If cursor1.RowCount > 0 Then
        For i = 0 To cursor1.RowCount - 1
            cursor1.Position = i
                
            Dim NewID As Int
            NewID = cursor1.GetInt("ID")
                
            Log(NewID)
            '    NewID = NewID +1
            'Dim acts As String=""
            Dim acts As String
    
            If acts="" Then
                'Dim acts As String = cursor1.Getstring("Account")
            End If
            If bkact <> Null Then
                'Dim acts As String = cursor1.Getstring("Account")
                acts =  bkact
            Else
                acts =  bkact
            End If
                
            If  bkact<> Null Then
                acts =  bkact
            Else
                Dim acts As String = cursor1.Getstring("Account")
            End If
            If acts="" Then
                Dim acts As String = cursor1.Getstring("Account")
            End If
    
    
        
            Dim ju As HttpJob
            ju.Initialize("", Me)
            ju.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBacademia.ashx?customerid=" & acts)
            ju.GetRequest.Timeout = 30000 ' 10 seconds
            Wait For (ju) JobDone(ju As HttpJob)
            If ju.Success Then ' if job is success (http status code 200)
                Dim RetVal As String
                RetVal = ju.GetString
        
                Dim jp As JSONParser
                jp.Initialize(ju.GetString)
                Log(jp) ' will pr
                Dim quotest As List = jp.NextArray
                For Each quot As Map In quotest
                    Log("Account: " & quot.Get("Account"))
                    Log("Grade: " & quot.Get("Grade"))
                    Log("Mids: " & quot.Get("Mid"))
                    Log("Ends: " & quot.Get("Ends"))
                    Log("Stream: " & quot.Get("Stream"))
                    Log("Names: " & quot.Get("Names"))
                    Log("Class: " & quot.Get("class"))
                    Log("Term: " & quot.Get("Term"))
                    Log("Subject: " & quot.Get("Subject"))
                    Log("Total: " & quot.Get("Total"))
                    Log("atk: " & quot.Get("autofield"))
                                    
                '    If quot.Get("Account")=acts Then
                        
                        Starter.SQL1.ExecNonQuery("INSERT INTO Academics VALUES('" & quot.Get("Names") & "','" & quot.Get("class") & "','" & quot.Get("Stream") & "','" & quot.Get("Subject")  & "','" & quot.Get("Total") & "','" & quot.Get("Grade") & "','" & quot.Get("Mid")  & "','" & quot.Get("Ends") & "','" & quot.Get("Term") & "','" & quot.Get("Years") & "','" & quot.Get("atk") & "')")
                        'query = "CREATE TABLE Academics ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total TEXT, Grade TEXT, Mid TEXT,Ends TEXT,Term TEXT, Years TEXT, id INTEGER )"
                        'ju.Release
                        'jt.Release
                        'jb.Release
                '    Else
                        'Dim jb As HttpJob
                        'jb.Initialize("", Me)
                        'jb.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBStartedacademic.ashx?customerid=" & acts)
                        ''j.Release
                    '    Dim jk As HttpJob
                    '    jk.Initialize("", Me)
                    '    jk.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBacademia.ashx?customerid=" & acts)
                    '    jk.GetRequest.Timeout = 30000 ' 10 seconds
                    '    Wait For (jk) JobDone(jk As HttpJob)
                    '    If jk.Success Then ' if job is success (http status code 200)
                        '    Dim RetVal As String
                        '    RetVal = jk.GetString
                        '    Log(RetVal)
        
        
                        '    Dim jp As JSONParser
                        '    jp.Initialize(jk.GetString)
                        '    Log(jp) ' will pr
                        '    Dim quotest As List = jp.NextArray
                        '    Starter.SQL1.ExecNonQuery("INSERT INTO Academics VALUES('" & quot.Get("Names") & "','" & quot.Get("class") & "','" & quot.Get("Stream") & "','" & quot.Get("Subject")  & "','" & quot.Get("Total") & "','" & quot.Get("Grade") & "','" & quot.Get("mid")  & "','" & quot.Get("Ends") & "','" & quot.Get("Term") & "','" & quot.Get("Years") & "','" & quot.Get("atk") & "')")
                        
                    '    End If
                '    End If
                    
                    
                
                Next
                

            End If
            ju.Release
            
            
            
            'jt.Release
            'jb.Release
            
    'Exit
        Next
        Msgbox("Records Processed Successfully. You Can Now Check ","SMIS")
        Return
    End If
    
    'ProgressDialogShow2("Looding Data",True)


Below is my log
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
** Activity (main) Pause, UserClosed = false **
** Activity (linkupdates) Create, isFirst = true **
** Activity (linkupdates) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
(JSONTokener)  at character 0 of [{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]
Name: MUTESASIRA FRANK
Category: Active
Froms: /Date(1533070800000)/
Tos: /Date(1545426000000)/
08/01/2018
01/08/2018
22/12/2018
22/12/2018
[{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]
1
Name: NAMIGADDE DEBORAH
Category: Active
Froms: /Date(1533070800000)/
Tos: /Date(1545426000000)/
01/08/2018
01/08/2018
22/12/2018
22/12/2018
[{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]
1
Name: NAHYENGWE AISHA
Category: Active
Froms: /Date(1533070800000)/
Tos: /Date(1545426000000)/
01/08/2018
01/08/2018
22/12/2018
22/12/2018
[{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]
1
Name: NKABIRWA TRIAL
Category: Active
Froms: /Date(1533070800000)/
Tos: /Date(1545426000000)/
01/08/2018
01/08/2018
22/12/2018
22/12/2018
[{"Account":"05-07152","Name":"MUTESASIRA FRANK","Stream":"W","Category":"Active","Country":"S2","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05586","Name":"NAMIGADDE DEBORAH","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-05603","Name":"NAHYENGWE AISHA","Stream":"A","Category":"Active","Country":"S6","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"},{"Account":"05-07924","Name":"NKABIRWA TRIAL","Stream":"B","Category":"Active","Country":"S1","Froms":"\/Date(1533070800000)\/","Tos":"\/Date(1545426000000)\/"}]
1
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
2
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
2
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
2
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
2
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
4
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
4
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
4
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
4
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
(JSONTokener)  at character 0 of [{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ACCOUNTS","Mid":22,"Ends":54,"Grade":"D1","Term":"TERM3","Years":"2018","Total":76,"autofield":1},{"Account":"05-07152","class":"S2","Stream":"W","Names":"MUTESASIRA FRANK","Subject":"ENGLISH","Mid":67,"Ends":53,"Grade":"D1","Term":"TERM3","Years":"2018","Total":80,"autofield":2},{"Account":"05-07924","class":"S1","Stream":"B","Names":"NKABIRWA TRIAL","Subject":"ACCOUNTS","Mid":22,"Ends":33,"Grade":"C5","Term":"TERM3","Years":"2018","Total":55,"autofield":3}]
Account: 05-07152
Grade: D1
Mids: 22
Ends: 54
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ACCOUNTS
Total: 76
atk: 1
Account: 05-07152
Grade: D1
Mids: 67
Ends: 53
Stream: W
Names: MUTESASIRA FRANK
Class: S2
Term: TERM3
Subject: ENGLISH
Total: 80
atk: 2
Account: 05-07924
Grade: C5
Mids: 22
Ends: 33
Stream: B
Names: NKABIRWA TRIAL
Class: S1
Term: TERM3
Subject: ACCOUNTS
Total: 55
atk: 3
 

MarkusR

Well-Known Member
Licensed User
Longtime User
i cant' follow, here u make a web request without wait for usage
B4X:
jbr.Initialize("", Me)
    jbr.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBStartedacademic.ashx?customerid=" & kt)
    'jb.GetRequest.Timeout=30000
    jbr.Release
    cursor1 = St

can't see where this comes from
B4X:
bkact

the dim between if then here is ugly because u use the variable outside of the condition.
and the dim of acts already exists.
B4X:
If acts="" Then
                Dim acts As String = cursor1.Getstring("Account")
            End If

here i suggest using sql parameters
B4X:
Starter.SQL1.ExecNonQuery("INSERT INTO Academics VALUES('" & quot.Get("Names") & "','" & quot.Get("class") & "','" & quot.Get("Stream") & "','" & quot.Get("Subject")  & "','" & quot.Get("Total") & "','" & quot.Get("Grade") & "','" & quot.Get("Mid")  & "','" & quot.Get("Ends") & "','" & quot.Get("Term") & "','" & quot.Get("Years") & "','" & quot.Get("atk") & "')")
                        'query = "CREATE TABLE Academics ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total TEXT, Grade TEXT, Mid TEXT,Ends TEXT,Term TEXT, Years TEXT, id INTEGER )"

better u rewrite this
B4X:
Dim acts As String
    
            If acts="" Then
                'Dim acts As String = cursor1.Getstring("Account")
            End If
            If bkact <> Null Then
                'Dim acts As String = cursor1.Getstring("Account")
                acts =  bkact
            Else
                acts =  bkact
            End If
                
            If  bkact<> Null Then
                acts =  bkact
            Else
                Dim acts As String = cursor1.Getstring("Account")
            End If
            If acts="" Then
                Dim acts As String = cursor1.Getstring("Account")
            End If
 
Upvote 0
Top