Hello community,
Merry Christmas to all!
I am struggling with not being able to list the result of job.GetString. Job.GetString drops the values as a single string like so:
214545437421454214374374534534534694694694. I am using DbUtils in a B4j server and I use ExecuteList via the Handle to receive data on a b4a app. But the way to add them to a separate list escapes me. I appreciate any example ...
Hi, the working code is just that I get all the elements from the b4j server as a single string. I need to receive separate data. The function reads the rows of a column from a Sqlite db.
B4J Server:
'Class module
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Public Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim lista As List
lista.Initialize
lista.Add(DBUtils.ExecuteList(Main.SQL1, "SELECT Cell FROM Tab", Null,0,lista))
Log(lista)
resp.Write(lista.Get(i))
End Sub
B4a Client:
Sub JobDone(j As HttpJob)
If j.Success Then
If j.JobName = "send object" Then
Log(j.GetString)
Else If j.JobName = "FunctionPulsanti" Then
Log(j.GetString) 'this: Log=2145454394394467467467'
End If
Else
Log("Error: " & j.ErrorMessage)
Msgbox(j.ErrorMessage, "Error")
End If
j.Release
ProgressDialogHide
End Sub
Code with Msgbox = broken code.
Code with Sub JobDone = deprecated code.
What is 'i' in the server code? You are sending a single element.
Best to use jRDC2.
If I remember correctly there is an ExecuteJson in DBUtils. You can use it to create a string with all elements.
Hi Erel,
(i) was not in use I did not darken it.
I am trying to submit 15 records of a column. I use DbUtils ver.2.11, and ExecuteJsone does not appear. I had already thought about creating a jsone map but I don't know where to start. So far I have implemented functions with mySql with php files on real servers. I'm not familiar with a b4j server. I followed your example to create the server but in the example you send data with EcecuteHtml.
Hi Erel,
I solved my problem!
I modified the DBUtils module and added a comma separator. Then I did a Split.
Added comma separator in DbUtils ExecuteList:
'Executes the query and fills the list with the values in the first column.
Public Sub ExecuteList(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, List1 As List)
List1.Clear
Dim Table As List
Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
If Table.Size = 0 Then Return
Dim Cols() As String
For i = 0 To Table.Size - 1
Cols = Table.Get(i)
List1.Add(","&Cols(0)) 'Add ,
Next
End Sub
Split execution in b4a:
Sub JobDone(j As HttpJob)
If j.Success Then
If j.JobName = "send object" Then
Log(j.GetString)
Else If j.JobName = "FunctionPulsanti" Then
Log(j.GetString) 'Now the received string is divided with the comma = 54,214, ....
Dim numbers() As String
numbers = Regex.Split(",", j.GetString)
Dim l As List
l.Initialize2(numbers) 'Adding individual items to the list
Log(l)
Else
Log("Error1: " & j.ErrorMessage)
'Msgbox(j.ErrorMessage, "Error1")
End If
j.Release
ProgressDialogHide
End Sub