Npgsql API Documentation

NpgsqlParameterCollection.Add Method (String, Object)

[This is preliminary documentation and subject to change.]

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name and value.

[Visual Basic]
Overloads Public Function Add( _
   ByVal parameterName As String, _
   ByVal value As Object _
) As NpgsqlParameter
public NpgsqlParameter Add(
   string parameterName,
   object value


The name of the NpgsqlParameter.
The Value of the NpgsqlParameter to add to the collection.

Return Value

The index of the new NpgsqlParameter object.


Use caution when using this overload of the Add method 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.

parameters.Add(":pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler will assume you are attempting to call the NpgsqlParameterCollection.Add(string, DbType) overload.

See Also

NpgsqlParameterCollection Class | Npgsql Namespace | NpgsqlParameterCollection.Add Overload List