Edit

Share via


OdbcParameterCollection.Add Method

Definition

Overloads

Add(OdbcParameter)

Adds the specified OdbcParameter to the OdbcParameterCollection.

Add(Object)

Adds the specified OdbcParameter object to the OdbcParameterCollection.

Add(String, OdbcType)

Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name and data type.

Add(String, Object)
Obsolete.
Obsolete.

Adds an OdbcParameter to the OdbcParameterCollection given the parameter name and value.

Add(String, OdbcType, Int32)

Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name, data type, and column length.

Add(String, OdbcType, Int32, String)

Adds an OdbcParameter to the OdbcParameterCollection given the parameter name, data type, column length, and source column name.

Add(OdbcParameter)

Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs

Adds the specified OdbcParameter to the OdbcParameterCollection.

public System.Data.Odbc.OdbcParameter Add (System.Data.Odbc.OdbcParameter value);

Parameters

value
OdbcParameter

The OdbcParameter to add to the collection.

Returns

The index of the new OdbcParameter object.

Exceptions

The OdbcParameter specified in the value parameter is already added to this or another OdbcParameterCollection.

The value parameter is null.

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Add(Object)

Source:
OdbcParameterCollectionHelper.cs
Source:
OdbcParameterCollectionHelper.cs
Source:
OdbcParameterCollectionHelper.cs

Adds the specified OdbcParameter object to the OdbcParameterCollection.

public override int Add (object value);
public int Add (object value);

Parameters

value
Object

A Object.

Returns

The index of the new OdbcParameter object in the collection.

Implements

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Add(String, OdbcType)

Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs

Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name and data type.

public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType);

Parameters

parameterName
String

The name of the parameter.

odbcType
OdbcType

One of the OdbcType values.

Returns

The index of the new OdbcParameter object.

Examples

The following example adds an OdbcParameter to the Parameters collection.

public void CreateParamCollection()
{
    OdbcCommand command = new OdbcCommand(
        "SELECT * FROM Customers WHERE CustomerID = ?", connection);
    OdbcParameterCollection paramCollection = command.Parameters;
    object paramObject = new OdbcParameter(
        "CustomerID", OdbcType.VarChar);
    int paramIndex = paramCollection.Add(paramObject);
}

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Add(String, Object)

Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs

Caution

Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.

Caution

Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202

Adds an OdbcParameter to the OdbcParameterCollection given the parameter name and value.

[System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.")]
public System.Data.Odbc.OdbcParameter Add (string? parameterName, object? value);
public System.Data.Odbc.OdbcParameter Add (string parameterName, object value);
[System.Obsolete("Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).  http://go.microsoft.com/fwlink/?linkid=14202", false)]
public System.Data.Odbc.OdbcParameter Add (string parameterName, object value);

Parameters

parameterName
String

The name of the parameter.

value
Object

The Value of the OdbcParameter to add to the collection.

Returns

The index of the new OdbcParameter object.

Attributes

Exceptions

The value parameter is not an OdbcParameter.

Remarks

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 integer 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 OdbcParameterCollection.Add overload.

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions (Obsolete)
.NET (8 (package-provided), 9 (package-provided))
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1)
.NET Standard (2.0 (package-provided))

Add(String, OdbcType, Int32)

Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs

Adds an OdbcParameter to the OdbcParameterCollection, given the parameter name, data type, and column length.

public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType, int size);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType, int size);

Parameters

parameterName
String

The name of the parameter.

odbcType
OdbcType

One of the OdbcType values.

size
Int32

The length of the column.

Returns

The index of the new OdbcParameter object.

Examples

The following example adds an OdbcParameter to the OdbcCommand.Parameters collection.

public void CreateOdbcParamColl(OdbcConnection connection)
{
    OdbcCommand command = new OdbcCommand(
        "SELECT * FROM Customers WHERE CustomerID = ?", connection);
    OdbcParameterCollection paramCollection = command.Parameters;
    OdbcParameter parameter = paramCollection.Add(
        "CustomerID", OdbcType.VarChar, 5);
}

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Add(String, OdbcType, Int32, String)

Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs
Source:
OdbcParameterCollection.cs

Adds an OdbcParameter to the OdbcParameterCollection given the parameter name, data type, column length, and source column name.

public System.Data.Odbc.OdbcParameter Add (string? parameterName, System.Data.Odbc.OdbcType odbcType, int size, string? sourceColumn);
public System.Data.Odbc.OdbcParameter Add (string parameterName, System.Data.Odbc.OdbcType odbcType, int size, string sourceColumn);

Parameters

parameterName
String

The name of the parameter.

odbcType
OdbcType

One of the OdbcType values.

size
Int32

The length of the column.

sourceColumn
String

The name of the source column.

Returns

The index of the new OdbcParameter object.

Examples

The following example adds an OdbcParameter to the Parameters collection.

public void CreateParameterCollection(OdbcConnection connection)
{
    OdbcCommand command = new OdbcCommand(
        "SELECT * FROM Customers WHERE CustomerID = ?", connection);
    OdbcParameterCollection paramCollection = command.Parameters;
    OdbcParameter parameter = paramCollection.Add(
        "CustomerID", OdbcType.VarChar, 5, "CustomerID");
}

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)