Syntax error?

[quote=93102:@Richard Summers] If TitleField.text <> “” And CodeField.text <> “” Then

// PREPARE THE STATEMENT
Dim ps As SQLitePreparedStatement = db.Prepare("UPDATE Snippets SET Title=?, Code=?, WHERE Title=?")
[/quote]

note no error check after the prepare
that would help in future

[quote=93352:@Norman Palardy]note no error check after the prepare
that would help in future[/quote]
Not that I’ve ever seen. I always check for db.error, but it’s never been true. Always the error will be “Unable to Prepare” on select or execute.

Norman is this a bug that should be raised in FB? Simple typo’s like this are incredibly hard to debug cause you just don’t see the issue, there’s no way to look at the actual built statement for correction and it’s only found way down the track when you execute or select and then the error message is excrement! (Ha foiled the bad taste editor in this forum!)

Norman - not quite sure I understand?

I have an error check, but it happens after the SQLExecute, as I thought that was the first time my code tries to do anything to the database?

Are you recommending that I somehow check that the prepared statement syntax is correct?
If so, How do I do that?

Thanks.

[quote=93409:@Wayne Golding]Not that I’ve ever seen. I always check for db.error, but it’s never been true. Always the error will be “Unable to Prepare” on select or execute.
[/quote]
Actually you’re correct
It doesn’t actually send anything to the DB until you try to execute as a prepared statement is just a statement with placeholders

Correct … my bad
You can’t check the error until you do the select or execute

I do wonder if we can get anything better than unable to prepare statement as an error message as that would have been really useful

Maybe you could change it so the error message says:

YOU HAVE AN EXTRA COMMA IN YOUR PREPARED STATEMENT - YOU BIG SILLY BILLY!
:slight_smile:

:stuck_out_tongue:
More likely the same thing that trying to run
db.SQLexecute(“UPDATE Snippets SET Title=?, Code=?, WHERE Title=?”)

which probably would be just a syntax error that MIGHT indicate there’s an extra comma

How about:

RELAX, DRINK A CUP OF CAMOMILE TEA, AND THEN RE-READ YOUR PREPARED STATEMENT - AS THE SYNTAX APPEARS TO BE INVALID - YOU BIG SILLY BILLY!

I’m afraid that’s the best I can come up with.
Let me know if it makes it into the next version, so I can tell all my friends :slight_smile: :slight_smile: :slight_smile: