According to MySql in this document C.7.9.6. Changes in MySQL Connector/NET 5.0.5 (07 March 2007):
Added
MySqlParameterCollection.AddWithValueand marked theAdd(name, value)method as obsolete.
I’ve been using .Add up until recently and experienced no problems. Upon discovering the .AddWithValue method, it is preferable primarily because it involves less syntax.
My question: does anyone know if there is any functional difference between the two methods? I cannot find proper documentation on them.
Edit:
Microsoft makes this note about SqlParameterCollection:
AddWithValuereplaces the
SqlParameterCollection.Addmethod that
takes a String and an Object. The
overload ofAddthat takes a string
and an object was deprecated because
of possible ambiguity with the
SqlParameterCollection.Addoverload
that takes a String and a SqlDbType
enumeration value where passing an
integer with the string could be
interpreted as being either the
parameter value or the corresponding
SqlDbType value. UseAddWithValue
whenever you want to add a parameter
by specifying its name and value.
Perhaps it is for the same reason.
When the documentation says nothing, consult the source.
These methods are identical (in their implementation):
http://mysql-connector-net-5.0.sourcearchive.com/documentation/5.0.8.1/parameter__collection_8cs-source.html