I have the following code that creates an SQLiteCommand
_deleteMergeWithBoth = new SQLiteCommand("delete from block where offset = ?1; delete from chunk where offset = ?1; delete from chunk where offset = ?2; update chunk set length = ?3 where offset = ?4", _db);
for (var i = 1; i <= 4; i++) _deleteMergeWithBoth.Parameters.Add(new SQLiteParameter(i.ToString(CultureInfo.InvariantCulture), DbType.Int64));
_deleteMergeWithBoth.Prepare();
The placeholders in the command (which has 4 statements) are in the format ?x with x being some digit.
The command works well as it is. However if i join the middle two statements so that they become
delete from chunk where offset in (?1,?2)
I suddenly get insufficient parameters supplied in the command. I had encountered a problem with parameters when using multiple statements in a single command. In that case I was simply using ? as a placeholder. That was solved by using numbered parameters. In this case however, I have no idea what I’m doing wrong. The placeholder clearly references ?2 and I do have a parameter called “2” associated with the command
Edit: I also tried using placeholders of a different format such as @parametername because I thought that maybe it was because of the numbers. I still got the same problem
I solved it by using named parameters of the format
@Xwith X being a letter. I thought I tried this before but it seems that I had made some error the first time (I have no idea what it was that made it fail the first time). This time it worked flawlessly