Android Question JRDC2 Update & Delete

stevetheframe

Member
Licensed User
Longtime User
I'm working with JRDC2 and sqlite. I can find examples of SELECT and INSERT, but not DELETE and UPDATE. Any pointers?
 

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Server:
upload_2019-6-1_20-56-8.png

B4X:
Dim ID As Int
ID = 2
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("UPDATE_table", Array (edtName.Text,edtLastName.Text,ID))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Update Successefull")
            Else
                Log("ERROR Update" & j.ErrorMessage)
            End If
            j.Release

Delete
B4X:
Dim ID As Int
ID = 2
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("Delete_Row", Array (ID))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Delete Row Successfull")
            Else
                Log("ERROR Delete Row " & j.ErrorMessage)
            End If
            j.Release

B4X:
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("Delete_table", Array (NameTable.Text))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Delete Table Successefull")
            Else
                Log("ERROR " & j.ErrorMessage)
            End If
            j.Release

Something like that, anything you tell me.
 
Upvote 0

stevetheframe

Member
Licensed User
Longtime User
I'm working with JRDC2 and sqlite. I can find examples of SELECT and INSERT, but not DELETE and UPDATE. Any pointers?
Server:
View attachment 80939
B4X:
Dim ID As Int
ID = 2
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("UPDATE_table", Array (edtName.Text,edtLastName.Text,ID))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Update Successefull")
            Else
                Log("ERROR Update" & j.ErrorMessage)
            End If
            j.Release

Delete
B4X:
Dim ID As Int
ID = 2
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("Delete_Row", Array (ID))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Delete Row Successfull")
            Else
                Log("ERROR Delete Row " & j.ErrorMessage)
            End If
            j.Release

B4X:
Dim req As DBRequestManager = CreateRequest
          Dim cmd As DBCommand = CreateCommand("Delete_table", Array (NameTable.Text))
            Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
            Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
            If j.Success Then
                Log("Delete Table Successefull")
            Else
                Log("ERROR " & j.ErrorMessage)
            End If
            j.Release

Something like that, anything you tell me.
Thanks. This is really helpful.
The DELETE works now (I'd got mixed up with arrays and brackets).
I'm still having problems with UPDATE, but I think this is unrelated ("values not bound to statement")
 
Upvote 0
Top