How can i check if there is no record returned by Json
B4X:
cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone FROM Register")
If cursor1.RowCount > 0 Then
' For i = 0 To cursor1.RowCount - 1
cursor1.Position =0
Dim phone As String
phone = cursor1.Getstring("Phone")
'Next
End If
Dim CustID As String = phone' Customer ID
Dim j As HttpJob
j.Initialize("", Me)
'j.Download("http://192.168.1.239/WebServicesula/Service.asmx/Get")
j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBPay.ashx?customerid=" & CustID)
'j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVB.ashx")
'j.PostString("http://192.168.1.239/Webandroid//VB.aspx?customerid=" & CustID)
j.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (j) JobDone(j As HttpJob)
If j.Success Then ' if job is success (http status code 200)
Dim RetVal As String
RetVal = j.GetString
Dim jp As JSONParser
jp.Initialize(j.GetString)
Log(jp) ' will pr
Dim quotes As List = jp.NextArray
For Each quot As Map In quotes
Log("CustomerId: " & quot.Get("CustomerId"))
Log("Name: " & quot.Get("Name"))
Log("Class: " & quot.Get("Class"))
Log("Stream: " & quot.Get("Stream"))
Log("Amount: " & quot.Get("Amount"))
Log("Dates: " & quot.Get("Dates"))
Log("Years: " & quot.Get("Years"))
Log("Term: " & quot.Get("Term"))
Log(DateTime.Date(JsonDateToTick( quot.Get("Dates"))))
Dim l As Long
DateTime.DateFormat = "dd/MM/yyyy" ' "1961-08-29"
Dim datestring As String = DateTime.Date(JsonDateToTick( quot.Get("Dates")))
l = DateTime.DateParse(datestring)
DateTime.DateFormat = "dd/MM/yyyy"
Log(DateTime.Date(l))
'Grab the last ID number which is the highest number
cursor1 = Starter.SQL1.ExecQuery("SELECT id FROM student")
'cursor1 = SQL1.ExecQuery("SELECT Phone FROM Register")
If cursor1.RowCount > 0 Then
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
Dim NewID As Int
NewID = cursor1.GetInt("id")
Next
End If
NewID = NewID +1 ' add 1 to the ID number to make a new ID field
Starter.SQL1.ExecNonQuery("INSERT INTO student VALUES('" & quot.Get("CustomerId") & "','" & quot.Get("Names") & "','" & quot.Get("Class") & "','" & quot.Get("Stream") & "','" & quot.Get("Amount") & "','" & DateTime.Date(l) & "','" & NewID & "','" & quot.Get("Years") & "','" & quot.Get("Term") & "')")
Next
Else
Msgbox("Records Not Processed. Please check Internet Connectivity and Try Try Again ","No Records Returned")
End If
Msgbox("Records Processed Successfully. You Can Now Check ","SMIS")
Log(RetVal) ' will print in log value returned from the server
j.Release