Android Question Using RDC for simple app

microbox

Active Member
Licensed User
Longtime User
Hello everyone,
Sorry if I'm still new to this....I manage to follow the RDC tutorial and run the server successfully. But I don't really understand when the following sql command executes in the config.properties file.
B4X:
#commands
sql.create_table=CREATE TABLE animals (\
    id INT NOT NULL AUTO_INCREMENT,\
    name CHAR(30) NOT NULL,\
    image BLOB,\
    PRIMARY KEY (id))
sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
sql.select_animal=SELECT name, image FROM animals WHERE name = ?
I also have the RemoteServerClient on my device. Where can I check if table "animals" is created? I have XAMPP installed but I see no table ('animals') created. And also in the device, how I can I display the query?

Thank you and kind regards,
microbox
 

microbox

Active Member
Licensed User
Longtime User
Thanks Erel.
Just to make it clear for me..
In the device, is the following code is connecting to the server with the following port(1778)?
B4X:
reqManager.Initialize(Me, "http://192.168.0.100:17178")
This is the event to call the function and send/trigger the command to the server?
B4X:
Sub Activity_Click
    GetAnimal("1")
End Sub
Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_animal"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
cmd.Name = "select_animal" means it's querying to the table. But I don't think the database is created yet.

Regards.
microbox
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
cmd.name should be sql.insert_animal i think. THIS is what in the config.properties are stored.
And, maybe, you should call cmd.name sql.create_table first if the database is not created.
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
@Manfred..thanks for the time. I'm still having trouble with given example in the rdc.
So far what I've done.
1. I identify the ip of the server laptop
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        reqManager.Initialize(Me, "http://192.168.1.101:17178")
    End If
End Sub
2. With tap event to call the following sub routine
B4X:
Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "create_table"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
But when trying to browse the "animals" table it is not showing up in xampp.
What do you think I'm doing wrong?

Thanks in advance,
microbox
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Hi Erel.. I placed a toast message but it turns out it's giving failed process.
B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Failed ", True)
    Else
        If Job.JobName = "DBRequest" Then
            Dim result As DBResult = reqManager.HandleJob(Job)
            reqManager.PrintTable(result)
            ToastMessageShow("Success ", True)
        End If
    End If
    Job.Release
End Sub
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Hi sorry for the delay...been busy at work.
I'm not really sure if this is the Log I need...but here it is.
B4X:
LogCat connected to: B4A-Bridge: LENOVO Lenovo A369i-863713026857874
--------- beginning of /dev/log/main
mWifiServiceMessenger == null
B4X:
If FirstTime Then
        reqManager.Initialize(Me, "http://192.168.1.100:17178") ' This is my wireless adapter
End If
 
Upvote 0
Top