I have the following code:
long[] conIds = GetIDs();
dc.ExecuteCommand("UPDATE Deliveries SET Invoiced = NULL WHERE ID IN {0}",conIds);
I’d expect that to work, but the executecommand statement throws an exception stating that
A query parameter cannot be of type int64[].
Why is this?
You are passing an array of longs into a placeholder where a string is expected. You need to convert the array into a concatenated string with comma delimiters. Then, pass that into the command text.
Depending on where else you are using the
GetIDsmethod, you could simplify your code by having that method return an array of strings. Then you can easily useString.Joinhere to convert that array to the concatenated text that you want.