SqlParameter with default value set to 0 doesn’t work as expected

Use caution when you use this overload
of the SqlParameter constructor to
specify integer parameter values.
Because this overload takes a value of
type Object, you must convert the
integral value to an Object type when
the value is zero, as the following C#
example demonstrates.

Parameter = new SqlParameter("@pname", Convert.ToInt32(0));

If you do not perform this conversion,
the compiler assumes that you are
trying to call the SqlParameter
(string, SqlDbType) constructor
overload.

Thanks Msdn 🙂

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)