First apologies as there are similar questions on this site, but none of them answer this problem directly.
Im using typed datasets in VS 2010. I create a TableAdapt
You also can create a list of IDs parameters so instead of using @IDs you will use @ID1, @ID2, @ID3, etc
var sql = "SELECT * from Table WHERE ID IN (" + getKeys(values.Count) + ")";
And getKeys(count) do something like this:
var result = string.Empty;
for (int i = 0; i < count; i++)
{
result += ", @ID" + i;
}
return string.IsNullOrEmpty(result) ? string.Empty : result.Substring(1);
and Finally, add the parameters:
foreach (int i = 0; i < values.Count; i++)
{
cmd.Parameters.Add(new SqlParameter("@ID" + i, SqlDbType.VarChar) { Value = values[i]});
}