Reputation: 3937
I'm executing a PetaPoco update statement like this:
db.Execute("UPDATE Content SET Html = '@0', PlainText = '@1' WHERE ContentId = @2", newHtml, newText, c.EmailContentId);
And the MySQL database is just sticking the parameter name into the field as a literal, i.e. the Html field now contains '@0' (without the quotes).
I've run queries like this a thousand times and I don't see the mistake in this line. I've stepped through the PetaPoco code and it creates the MySqlCommand, which has a MySqlParameterCollection, which has 3 parameters, and they all have the correct values.
Any idea where I'm going wrong?
Upvotes: 0
Views: 478
Reputation: 10336
If you're using prepared statements, you've got to omit single quotes around your placeholders. Use
db.Execute("UPDATE Content SET Html = @0, PlainText = @1 WHERE ContentId = @2", newHtml, newText, c.EmailContentId);
instead.
Upvotes: 3