When the user clicks at a list entry, I want to open a new activity with details to the entry. The data is coming from sql-server via RDC.
I found no working way to have all the code, that is needed to get the DBResult-object, in a seperat module.
My goal was to be able to have something simple like:
But I found no way to let the sub wait, till the DBResult is read to use.
The only working solution is to have all this code in each sub:
It also seems that I have to have this in each activity, cause it was not working, when I had it in a own module.
So, is there any way to have less code, when retrieve data from RDC in several subs/activities?
I found no working way to have all the code, that is needed to get the DBResult-object, in a seperat module.
My goal was to be able to have something simple like:
B4X:
Sub ShowDetails(KL_ID As Int)
Dim res As DBResult = dbHelper.GetResult("select_Klient",KL_ID")
Dim dt As DBResult = res
Dim dr() As Object = res.Rows.Get(0)
txt_Nachname.Text = dr(dt.Columns.Get("Nachname"))
txt_Vorname.Text = dr(dt.Columns.Get("Vorname"))
End Sub
But I found no way to let the sub wait, till the DBResult is read to use.
The only working solution is to have all this code in each sub:
B4X:
Dim req As DBRequestManager = CreateRequest(Me)
Dim cmd As DBCommand = CreateCommand("select_Klient", Array(KL_ID))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(Res As DBResult)
Else
Log("ERROR: " & j.ErrorMessage)
Return
End If
j.Release
It also seems that I have to have this in each activity, cause it was not working, when I had it in a own module.
B4X:
Sub CreateRequest(Target As Object) As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Target, "http://80.121.139.239:17178/rdc")
Return req
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
So, is there any way to have less code, when retrieve data from RDC in several subs/activities?