Export (0) Print
Expand All

OdbcParameterCollection.Add Method (String, OdbcType, Int32, String)

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

Namespace:  System.Data.Odbc
Assembly:  System.Data (in System.Data.dll)

public OdbcParameter Add(
	string parameterName,
	OdbcType odbcType,
	int size,
	string sourceColumn


Type: System.String

The name of the parameter.

Type: System.Data.Odbc.OdbcType

One of the OdbcType values.

Type: System.Int32

The length of the column.

Type: System.String

The name of the source column.

Return Value

Type: System.Data.Odbc.OdbcParameter
The index of the new OdbcParameter object.

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");

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft