Export (0) Print
Expand All

OdbcParameterCollection Class

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

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

public sealed class OdbcParameterCollection : DbParameterCollection
public final class OdbcParameterCollection extends DbParameterCollection
public final class OdbcParameterCollection extends DbParameterCollection

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.

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

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 ExecuteStoredProcedure(OdbcConnection connection) 
{
    OdbcCommand command = connection.CreateCommand();
    command.CommandText = "{ call MoneyProcedure(?,?,?) ";

    command.Parameters.Add("", OdbcType.Int).Value = 1;
    command.Parameters.Add("", OdbcType.Decimal).Value = 2;
    command.Parameters.Add("", OdbcType.Decimal).Value = 3;


System.Object
   System.MarshalByRefObject
     System.Data.Common.DbParameterCollection
      System.Data.Odbc.OdbcParameterCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft