What am I missing?

Hey everyone.

So very tired… I’ve read this over and over again and I cannot see why it’s not updating like it should. No errors, just no update. If anyone can see my error, I’d be very grateful.

Var ps As SQLitePreparedStatement
ps = SQLitePreparedStatement(App.DB.Prepare(“UPDATE projects SET mod_date = ? WHERE project_title = ?;”))
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)

ps.ExecuteSQL("" +Today+ ", " + thisStory + “”)

Put your , in the correct place in the executesql

ps.ExecuteSQL(Today, thisStory)

Hey Julian. Please excuse me. I’m staring at it and it looks right.

No worries, did the edit come through with the right syntax? I posted the initial comment on my mobile and put the syntax in on my pc.

What you’ve got there is one big string that looks like this:

"somedate, sometitle"

But you actually want to send over the two variables separately to the prepared statement, so you pass them in separately as I posted above.

So, the correct result syntax should read ps.ExecuteSQL(some day, some story). Yeah? And I believe I need to quote out the Var names so ps.ExecuteSQL(""+Today+"", “”+thisStory+"") but that results in ps.ExecuteSQL(“some date”, “some story”) If I reduce the quotes as ps.ExecuteSQL("+Today+", “+thisStory+”), the IDE flags the variables as unused and, as you’ve pointed out, if I double quote either end, I’m passing a single string, not two.

No, it needs to be like this, as I put right at the top:

If Today and thisStory are your variables.

Are you using Xojo 2019r1 or earlier?

If not, this syntax should be much easier:

Var values() As Variant
values.AddRow Today
values.AddRow thisStory

Var sql As String = "UPDATE projects SET mod_date = ? WHERE project_title = ?;"

App.DB.ExecuteSQL(sql, values)

Aha! So I don’t need to isolate the variable names?? That’s what’s had me thrown!

Thanks for your patience Julian.

1 Like

Hey Jeremie

I’m using the current version but, as I’m new to Xojo, I’m referencing the docs.

I’ll take your syntax for a run.

Thank you.