OdbcParameterCollection.Add Method (String, OdbcType, Int32)

 

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

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

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

Parameters

parameterName
Type: System.String

The name of the parameter.

odbcType
Type: System.Data.Odbc.OdbcType

One of the OdbcType values.

size
Type: System.Int32

The length of the column.

Return Value

Type: System.Data.Odbc.OdbcParameter

The index of the new OdbcParameter object.

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

.NET Framework
Available since 1.1
Return to top
Show: