Android Question ExecuteCommand - No value specified for parameter 2

Setlodi

Member
Hi There

I have been looking at this code for a long long time and I can't seem to identify the issue here. The following code gives me an error:

B4X:
Public Sub Delete_Officer_From_DB(delOfficerIDNo As Int)
    delOfficerIDNo = 222
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("Delete_Officer", Array(delOfficerIDNo))
'    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    Wait For (req.ExecuteCommand(cmd, Null)) JobDone(j As HttpJob)
    If j.Success Then
        Log("Officer deleted from DB successfully!")
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub

As you can see I was using ExecuteQuery and I got this error from the server:
B4X:
(SQLException) java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
Command: , took: 8ms, client=105.209.231.27

After changing to ExecuteCommand I get this error:
B4X:
(SQLException) java.sql.SQLException: No value specified for parameter 2
(EofException) org.eclipse.jetty.io.EofException: Closed
Command: , took: 7ms, client=105.209.231.27

config.properties file:
B4X:
sql.Delete_Officer= DELETE FROM Officers_Table WHERE OfficerIDNo = ?

Officers_Table, OfficerIDNo and record with OfficerIDNo = 222 all exist in the database.

Please help me
 

Setlodi

Member
Thank you for your response Erel. Sorry, I made a mistake. After going through the config.properties file for the 100th time I discovered that there was another Delete_Officer sql string which I used earlier in the day to test the code. It had 2 parameters! After deleting it the app is now working as expected.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…