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?
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.
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.
@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?
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
@DonManfred is correct. Even if you are using the emulator you cannot access the PC with 127.0.0.1. You can however with the emulator use address 10.0.2.2. It will point to the host address.