It happens when it is in a procedure is in loop if you are running this code block in a for loop against some array of values.
In that case, you would need to add the parameters collection to the
command object only once and before specifying the values for the
This should be the right way.
SqlParameter myParam = new SqlParameter("@username",SqlDbType.VarChar);
foreach(string user in userNames)
myParam.Value = user;
hope this will help you