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
Not applicable.

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

 }

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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft