OdbcParameterCollection OdbcParameterCollection OdbcParameterCollection OdbcParameterCollection Class

Definition

Represents a collection of parameters relevant to an OdbcCommand and their respective mappings to columns in a DataSet. This class cannot be inherited.

public ref class OdbcParameterCollection sealed : System::Data::Common::DbParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class OdbcParameterCollection : System.Data.Common.DbParameterCollection
type OdbcParameterCollection = class
    inherit DbParameterCollection
Public NotInheritable Class OdbcParameterCollection
Inherits DbParameterCollection
Inheritance
OdbcParameterCollectionOdbcParameterCollectionOdbcParameterCollectionOdbcParameterCollection
Attributes

Examples

The following example assumes that the data source has a table named MoneyTable and a stored procedure named MoneyProcedure, which are defined as follows:

CREATE TABLE MoneyTable (col1 int, col2 smallmoney, col3 decimal);  

CREATE PROC MoneyProcedure (@p1 int, @p2 smallmoney, @p3 decimal)   
AS   
INSERT INTO MyTable VALUES (@p1, @p2, @p3);  

The example creates parameters and calls the MoneyProcedure stored procedure.

public void CreateMyProc(OdbcConnection connection)
{
    OdbcCommand command = connection.CreateCommand();
    command.CommandText = "{ call MyProc(?,?,?) }";

    OdbcParameter param = new OdbcParameter();
    param.DbType = DbType.Int32;
    param.Value = 1;
    command.Parameters.Add(param);

    param = new OdbcParameter();
    param.DbType = DbType.Decimal;
    param.Value = 1;
    command.Parameters.Add(param);

    param = new OdbcParameter();
    param.DbType = DbType.Decimal;
    param.Value = 1;
    command.Parameters.Add(param);

    command.ExecuteNonQuery();

 }
Public Sub CreateMyProc(ByVal connection As OdbcConnection)

  Dim command As OdbcCommand = connection.CreateCommand()
  Command.CommandText = "{ call MyProc(?,?,?) }"

  Dim param As New OdbcParameter()
  param.DbType = DbType.Int32
  param.Value = 1
  command.Parameters.Add(param)

  param = New OdbcParameter()
  param.DbType = DbType.Decimal
  param.Value = 1
  command.Parameters.Add(param)

  param = New OdbcParameter()
  param.DbType = DbType.Decimal
  param.Value = 1
  command.Parameters.Add(param)

  command.ExecuteNonQuery()

End Sub

Remarks

The number of parameters in the collection must equal the number of parameter placeholders within the command text, or else the .NET Framework Data Provider for ODBC raises an error.

Properties

Count Count Count Count

Returns an Integer that contains the number of elements in the OdbcParameterCollection. Read-only.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

Gets a value that indicates whether the OdbcParameterCollection has a fixed size. Read-only.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value that indicates whether the OdbcParameterCollection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

Gets a value that indicates whether the OdbcParameterCollection is synchronized. Read-only.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the OdbcParameter at the specified index.

Item[String] Item[String] Item[String] Item[String]

Gets or sets the OdbcParameter with the specified name.

SyncRoot SyncRoot SyncRoot SyncRoot

Gets an object that can be used to synchronize access to the OdbcParameterCollection. Read-only.

Methods

Add(Object) Add(Object) Add(Object) Add(Object)

Adds the specified OdbcParameter object to the OdbcParameterCollection.

Add(OdbcParameter) Add(OdbcParameter) Add(OdbcParameter) Add(OdbcParameter)

Adds the specified OdbcParameter to the OdbcParameterCollection.

Add(String, Object) Add(String, Object) Add(String, Object) Add(String, Object)

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

Add(String, OdbcType) Add(String, OdbcType) Add(String, OdbcType) Add(String, OdbcType)

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

Add(String, OdbcType, Int32) Add(String, OdbcType, Int32) Add(String, OdbcType, Int32) Add(String, OdbcType, Int32)

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

Add(String, OdbcType, Int32, String) Add(String, OdbcType, Int32, String) Add(String, OdbcType, Int32, String) Add(String, OdbcType, Int32, String)

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

AddRange(Array) AddRange(Array) AddRange(Array) AddRange(Array)

Adds an array of values to the end of the OdbcParameterCollection.

AddRange(OdbcParameter[]) AddRange(OdbcParameter[]) AddRange(OdbcParameter[]) AddRange(OdbcParameter[])

Adds an array of OdbcParameter values to the end of the OdbcParameterCollection.

AddWithValue(String, Object) AddWithValue(String, Object) AddWithValue(String, Object) AddWithValue(String, Object)

Adds a value to the end of the OdbcParameterCollection.

Clear() Clear() Clear() Clear()

Removes all OdbcParameter objects from the OdbcParameterCollection.

Contains(Object) Contains(Object) Contains(Object) Contains(Object)

Determines whether the specified Object is in this OdbcParameterCollection.

Contains(OdbcParameter) Contains(OdbcParameter) Contains(OdbcParameter) Contains(OdbcParameter)

Determines whether the specified OdbcParameter is in this OdbcParameterCollection.

Contains(String) Contains(String) Contains(String) Contains(String)

Gets a value indicating whether an OdbcParameter object with the specified parameter name exists in the collection.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Copies all the elements of the current OdbcParameterCollection to the specified one-dimensional Array starting at the specified destination Array index.

CopyTo(OdbcParameter[], Int32) CopyTo(OdbcParameter[], Int32) CopyTo(OdbcParameter[], Int32) CopyTo(OdbcParameter[], Int32)

Copies all the elements of the current OdbcParameterCollection to the specified OdbcParameterCollection starting at the specified destination index.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the OdbcParameterCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(Object) IndexOf(Object) IndexOf(Object) IndexOf(Object)

Gets the location of the specified Object within the collection.

IndexOf(OdbcParameter) IndexOf(OdbcParameter) IndexOf(OdbcParameter) IndexOf(OdbcParameter)

Gets the location of the specified OdbcParameter within the collection.

IndexOf(String) IndexOf(String) IndexOf(String) IndexOf(String)

Gets the location of the specified OdbcParameter with the specified name.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object)

Inserts a Object into the OdbcParameterCollection at the specified index.

Insert(Int32, OdbcParameter) Insert(Int32, OdbcParameter) Insert(Int32, OdbcParameter) Insert(Int32, OdbcParameter)

Inserts a OdbcParameter object into the OdbcParameterCollection at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Remove(Object) Remove(Object) Remove(Object) Remove(Object)

Removes the Object object from the OdbcParameterCollection.

Remove(OdbcParameter) Remove(OdbcParameter) Remove(OdbcParameter) Remove(OdbcParameter)

Removes the OdbcParameter from the OdbcParameterCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the OdbcParameter from the OdbcParameterCollection at the specified index.

RemoveAt(String) RemoveAt(String) RemoveAt(String) RemoveAt(String)

Removes the OdbcParameter from the OdbcParameterCollection with the specified parameter name.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also