OdbcParameterCollection.Add Method (String, OdbcType)


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

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

public OdbcParameter Add(
	string parameterName,
	OdbcType odbcType


Type: System.String

The name of the parameter.

Type: System.Data.Odbc.OdbcType

One of the OdbcType values.

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

.NET Framework
Available since 1.1
Return to top