It's really stupid what you have to do in this situation. You have to add a parameter for each value in the IN
list.
So your query would end up something like this:
SELECT * FROM Customer WHERE ID in (@parmCustId1, @parmCustId2, @parmCustId3 ... @parmCustId<N>)
Then your code would look something like this:
var query = "select * from Customer where ID in (@parmCustId)";
using (AseCommand cmd = new AseCommand("", conn))
{
var replacement = "";
for (int i = 0; i < arrList.Length; i++)
{
var id = arrList[i];
var p = "@parmCustId" + i.ToString();
cmd.Parameters.AddWithValue(p, id);
replacement += p;
if (i != arrList.Length - 1)
{
replacement += ",";
}
}
cmd.CommandText = query.Replace("@parmCustId", replacement);
using (AseDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
//do something
}
}
}
There's also some libraries that will support this. For example, Dapper, written by the folks here at StackOverflow, will support this with ease. It's also a super fast and efficient object relational mapper (ORM) that can make some of the DataReader logic simpler if you're putting into an object. You can get it on NuGet.