Android Question update sql string

Makumbi

Well-Known Member
Licensed User
i have written this small code my it does not update my table as i required

i wanted the phone number to be update by the newphone and the code to also be updated to the new code but when i check i dont see any changes to my table please help
B4X:
Dim sqlString As String
                sqlString ="UPDATE Register SET Phone = ?, code = ? Where Phone = ? AND code = ?"
                cursor1 =Starter.SQL1.ExecQuery2(sqlString ,Array As String(Newnumber.Text, Codenewn.Text,Oldn.Text,Codeolda.Text))
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Try:

B4X:
    Dim sqlString As String
    sqlString ="UPDATE Register SET Phone = ?, code = ? Where Phone = ? AND code = ?"
    Starter.SQL1.ExecNonQuery2(sqlString ,Array As String(Newnumber.Text, Codenewn.Text,Oldn.Text,Codeolda.Text))

An update query doesn't return a result. You only need to use a cursor where you are returning records as a result of your query. You can't do an update & return records at the same time (actually you could, but you'd need to use a stored procedure).

- Colin.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…