Hi Community,
Please, i have this workings code which works for my local sqlite db but how do i convert the part of the code to work for an online database.
I have added the part of the working code with the sqlite db which i want to covert. and what i have done so far with the converting which is not working.
Please, all I'm just trying to do is to use HttpJob to get the query response from my php script.
The working code with sqlite
What i have done so far but not working.
Please, i have this workings code which works for my local sqlite db but how do i convert the part of the code to work for an online database.
I have added the part of the working code with the sqlite db which i want to covert. and what i have done so far with the converting which is not working.
Please, all I'm just trying to do is to use HttpJob to get the query response from my php script.
The working code with sqlite
B4X:
Dim rs1 As ResultSet
strQuery = $"SELECT DISTINCT POSITION FROM ${TableName} ORDER BY POSITION"$
rs1 = Starter.SQL.ExecQuery(strQuery)
Do While rs1.NextRow
Dim MyPosition As String =rs1.GetString("POSITION")
Log(MyPosition)
AddTitle(MyPosition)
Dim rs As ResultSet
strQuery=$"SELECT * FROM ${TableName} WHERE POSITION LIKE ? ORDER BY POSITION"$
rs=Starter.SQL.ExecQuery2(strQuery, Array As String(MyPosition))
Do While rs.NextRow
Dim TD As TestData
TD.Initialize
TD.strPosition =rs.GetString("POSITION")
TD.strname =rs.GetString("NAME")
Dim b() As Byte
b = rs.GetBlob("PIC")
If b <> Null Then
TD.img = BytesToBmp(b)
Else
TD.img = LoadBitmapResize(File.DirAssets, "Hannibal.jpg", 40dip, 40dip, True)
End If
Dim Pnl As B4XView = xui.CreatePanel(Null) '
Pnl.SetLayoutAnimated(0dip, 0dip,0dip, CLV1.AsView.Width, itemHeight)
CLV1.Add(Pnl, TD)
Loop
rs.Close
Loop
rs1.Close
What i have done so far but not working.
B4X:
Dim a As HttpJob
a.Initialize("a",Me)
a.PostString(Main.strURL & "CANDIDATE/candidate.php",$"Action=category&ENAME=${EN}"$)
ProgressDialogShow2("L o a d i n g",False)
Wait For(a) JobDone(q As HttpJob)
If q.Success Then
' ProgressDialogHide
Dim ret As String
'Dim act As String
ret =q.GetString
'#if debug
Log(ret)
'#End if
Dim parser As JSONParser
parser.Initialize(ret)
Dim Data As List
Data = parser.NextArray 'returns a list with ma
For i = 0 To Data.Size - 1
Dim ma As Map
ma = Data.Get(i)
Dim MyPosition As String =ma.Get("POSITION")
AddTitle(MyPosition)
Dim a1 As HttpJob
a1.Initialize("a1",Me)
a1.PostString(Main.strURL & "CANDIDATE/candidate.php",$"Action=candidate&Poll=${EN}&Position=${MyPosition}"$)
ProgressDialogShow2("L o a d i n g ..",False)
Wait For(a1) JobDone(q1 As HttpJob)
If q1.Success Then
ProgressDialogHide
Dim ret1 As String
ret1 =q1.GetString
'#if debug
Log(ret1)
'#End if
Dim parser1 As JSONParser
parser1.Initialize(ret1)
Dim Data1 As List
Data1 = parser1.NextArray 'returns a list with ma
For i = 0 To Data1.Size - 1
Dim ma1 As Map
ma1 = Data1.Get(i)
Dim TD As TestData
TD.Initialize
TD.strPosition =ma1.Get("POSITION")
TD.strname =ma1.Get("FULLNAME")
If ma1.Get("PIC")="" Or ma1.Get("PIC")=Null Then
TD.img =LoadBitmap(File.DirAssets,"index.png")
Else
Dim b As String=ma1.Get("PIC")
Dim job6 As HttpJob
job6.Initialize( "", Me )
job6.Download( b )
Wait For (job6) JobDone( job7 As HttpJob )
If job7.Success Then
'Dim
TD.img= job7.GetBitmapResize(80%x,100%y,True)
job7.Release
End If
End If
Dim Pnl As B4XView = xui.CreatePanel(Null) '
Pnl.SetLayoutAnimated(0dip, 0dip,0dip, CustomListView1.AsView.Width, itemHeight)
CustomListView1.Add(Pnl, TD)
Next
ProgressDialogHide
q1.Release
End If
Next
ProgressDialogHide
End If
q.Release
Last edited: