Update a row in SQLite

I have a weblistbox that is updated from an SQLite table on action.open. The first column contains the RowID of the database table. This is defined auto increment primary key.

I can insert and delete table entries and add or remove from the database table but i can’t get my head around updating the database table.

I can read the data from the weblistbox, which came from the table, edit the contents, write the data back to the weblistbox, but I cannot update the specific row in the database table.

I am using prepared statements for the other functions.

Any help would be greatly appreciated as I learn how to do this.

what have you tried ?
it literally should be no harder than writing

update <tablename> set <column> = <value> [, <column> = <value>]* where rowid = rowtag value

the reason I wrote [, = ]* is you can update as many columns as you want

whether its in a prepared stmt or not the syntax is the same for the update stmt

Thanks Norman,

That’s what I thought but it doesn’t change the value in the table i.e. I change contents of the “descriptor” column and I do the update. I don’t get a dberror and the data isn’t changed when I reload the weblistbox from the table. I’ll recheck my rowid method to make sure this isn’t my problem. I am using here the in-line sql statement.

With the prepared statement am I correct with this method:

update set <column = ?, set column1 = ? where rowed = ?
db.bind(0,descriptor.text)
db.bind(1,name.text)
db.bind(2,rowidvalue)

Did you .Commit() the changes?

Good call Tim. As a newbie that was one of my first mistakes. But not this time.

I am checking my rowid method. From the comments so far I am pretty sure I have something wrong in there.

Your example code shows “rowed”. Should it not be “rowed”?

Also, you have shown that you use the “set column” each time. You only use the keyword “set” once. So, your code should be:

update <tablename> set column = ?, column1 = ? where rowid = ? db.bind(0,descriptor.text) db.bind(1,name.text) db.bind(2,rowidvalue)

Thanks Simon,

Yes it should be rowid (darned autocorrect… if I write rowed it autocorrects it to rowid but if I write rowid it autocorrects it to rowed… I can’t win).

Thanks for the syntax correction as well.