You are adding each parameter to the collection twice. Your code is using a pattern:
parameter = cmd.Parameters.Add(name, type);
parameter.Value = value;
cmd.Parameters.Add(parameter);
either remove the last
Add(parameter)
statement, or use a pattern like:
parameter = cmd.CreateParameter(name, type);
parameter.Value = value;
cmd.Parameters.Add(parameter);
or even change the
cmd.CreateParameter
to simply
new SQLParameter
(or whichever Db prefix you're using)