Share via


OdbcParameterCollection 类

表示与 OdbcCommand 相关的参数的集合以及各个参数到 DataSet 中列的映射。无法继承此类。

**命名空间:**System.Data.Odbc
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public NotInheritable Class OdbcParameterCollection
    Inherits DbParameterCollection
用法
Dim instance As OdbcParameterCollection
public sealed class OdbcParameterCollection : DbParameterCollection
public ref class OdbcParameterCollection sealed : public DbParameterCollection
public final class OdbcParameterCollection extends DbParameterCollection
public final class OdbcParameterCollection extends DbParameterCollection

备注

集合中参数的数目必须与命令文本中参数占位符的数目相等,否则用于 ODBC 的 .NET Framework 数据提供程序将引发错误。

示例

下面的示例假定:数据源具有表名 MoneyTable 和名为 MoneyProcedure 的存储过程,其定义方式如下:

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

该示例创建参数并调用 MoneyProcedure 存储过程。

Public Sub ExecuteStoredProcedure(connection As OdbcConnection)
    Dim command As OdbcCommand = 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
End Sub 
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

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1

请参见

参考

OdbcParameterCollection 成员
System.Data.Odbc 命名空间

其他资源

使用命令
将参数用于 DataAdapter