Sqlite PreparedStatement Update more than one item in a record

I can’t find any sample code to be able update more than one item in a record with the PreparedStatement. I bought a pdf book that gives an sample to update one item. The SET with wildcard ? is the one I need to know the proper syntax to do it to bind the to Bind the 2 items below in the sample code.

//These 2 have proven to be wrong by trial and error how do I do the wildcard ? syntax for SET
“UPDATE dbTable SET Col_1 = ?, Col_2 = ? WHERE ID = ?” // Syntax Error
“UPDATE dbTable SET Col_1, Col_2 = ?, ? WHERE ID = ?” // Syntax Error

[code]//Update the data in the database with a PreparedSQLStatement for one item
Dim ps as PreparedSQLStatement = db.Prepare (“UPDATE dbTable SET Col_1 = ? WHERE ID = ?”)
ps.BindType (0, SQLitePreparedStatement.SQLITE_INTEGER)
ps.BindType (1, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType (2, SQLitePreparedStatement.SQLITE_INTEGER)
ps.Bind (0, 0) //ID
ps.Bind (1, “Text_1”)
ps.Bind (2, 10)

ps.SQLExecute[/code]

Bind and BindType start at index 0. Could that be the issue?

Hi Kem
Yes that part I was just re-editied the code. Yes it would be ROW 0 then update the 2 records in that row. Does the ID row have to get a Bind and Bind type for the WHERE ID = ?

you must Bind every “?” in the order they appear (ID is last in the statement, but first in you bind index)

but you have two “?” and 3 binds

Either there is still an error in your code or there is a misunderstanding about how Prepared Statements work, so let me try it this way.

When you have a statement that includes X placeholders, you will also have X BindType/Bind statements to fill in those placeholders. The index of the first placeholder is 0.

In the code above you have two placeholders for Col_1 and ID, but three BindType/Bind statements. I’d expect this to throw an exception of some type at best, or fail silently at worst.

For your original question, this should work:

UPDATE dbTable SET Col_1 = ?, Col_2 = ? WHERE ID = ?

as long as you also have three BindType/Bind statements starting at index 0.

So every wildcard ? has to have a bind and that’s why i was getting a syntax error.

Thanks again guys