Given the following line of code:
cmd.Parameters.Add(new SqlParameter("@displayId", SqlDbType.NVarChar).Value = customer.DisplayID);
I receive the following error: The SqlParameterCollection only accepts non-null SqlParameter type objects, not String objects.
However, rewriting it to use object intialization:
cmd.Parameters.Add(new SqlParameter("@displayId", SqlDbType.NVarChar) { Value = customer.DisplayID });
works just fine. Any pointer on why this is occuring?