Duplicate of this question, as it was not answered to satisfaction. Delete where in clause in sqlite
In virtually the exact same scenario as the original poster, Cholo, I am attempting a simple parameterised Delete statement.
string UIDcsv = "1, 2, 3, 4, 5, 6";
Console.WriteLine(UIDcsv);
var sqlite_DeleteEmployee = new SQLiteCommand(sqlite_Conn);
sqlite_DeleteEmployee.CommandText = "DELETE FROM myTable WHERE UID IN (@x);";
sqlite_DeleteEmployee.Parameters.AddWithValue("@x", UIDcsv);
sqlite_DeleteEmployee.Prepare();
sqlite_DeleteEmployee.ExecuteNonQuery();
Like Cholo found in the linked 'Accepted Answer', the code runs fine but does not actually execute this statement. This has been frustrating me all evening!
Now I've written this, I'm looking at rest of my code and realising that this C# Sql command generator is more than likely auto-appending quotation marks around @xyz in the command, turning the list of UIDs into a single string. How do I stop this happening?
Output of the WriteLine:
1, 2, 3, 4, 5, 6