.NET Framework Class Library IDataParameter Interface Represents a parameter to a Command object, and optionally, its mapping to DataSet columns; and is implemented by .NET Framework data providers that access data sources.
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
Public Interface IDataParameter
public interface IDataParameter
public interface class IDataParameter
type IDataParameter = interface end
The IDataParameter type exposes the following members.

Remarks
The IDataParameter interface allows an inheriting class to implement a Parameter class, which represents a parameter to a Command object. For more information about Parameter classes, see Configuring Parameters and Parameter Data Types (ADO.NET). An application does not create an instance of the IDataParameter interface directly, but creates an instance of a class that inherits IDataParameter. Classes that inherit IDataParameter must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IDataParameter interface defines the DbType property. In turn, the OleDbParameter class inherits this property, and also defines the OleDbType property. Notes to ImplementersTo promote consistency among .NET Framework data providers, name the inheriting class in the form Prv Parameter where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, Sql is the prefix of the SqlCommand class in the System.Data.SqlClient namespace. When you inherit from the IDataParameter interface, you should implement the following constructors: Item | Description |
|---|
PrvParameter() | Initializes a new instance of the Parameter class. | PrvParameter(string name, PrvDbType dataType) | Initializes a new instance of the Parameter class with the parameter name and data type. | PrvParameter(string name, object value) | Initializes a new instance of the Parameter class with the parameter name and an object that is the value of the Parameter. | PrvParameter(string name, PrvDbType dataType, int size) | Initializes a new instance of the Parameter class with the parameter name, data type, and width. | PrvParameter(string name, PrvDbType dataType, int size, string srcColumn) | Initializes a new instance of the DbParameter class with the parameter name, data type, width, and source column name. | PrvParameter(string parameterName, PrvDbType dbType, int size, ParameterDirection direction, Boolean isNullable, Byte precision, Byte scale, string srcColumn, DataRowVersion srcVersion, object value) | Initializes a new instance of the OleDbParameter class with the parameter name, data type, width, source column name, parameter direction, numeric precision, and other properties. |

Examples
The following example creates multiple instances of the derived class, SqlParameter, through the SqlParameterCollection collection within the SqlDataAdapter. These parameters are used to select data from the data source and place the data in the DataSet. This example assumes that a DataSet and a SqlDataAdapter have already been created with the appropriate schema, commands, and connection.
Public Sub AddSqlParameters()
' ...
' create categoriesDataSet and categoriesAdapter
' ...
categoriesAdapter.SelectCommand.Parameters.Add( _
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters"
categoriesAdapter.SelectCommand.Parameters.Add( _
"@SerialNum", SqlDbType.Int).Value = 239
categoriesAdapter.Fill(categoriesDataSet)
End Sub
public void AddSqlParameters()
{
// ...
// create categoriesDataSet and categoriesAdapter
// ...
categoriesAdapter.SelectCommand.Parameters.Add(
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters";
categoriesAdapter.SelectCommand.Parameters.Add(
"@SerialNum", SqlDbType.Int).Value = 239;
categoriesAdapter.Fill(categoriesDataSet);
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework IDataParameter (Interfaz) Representa un parámetro para un objeto Command y, de forma opcional, su asignación a columnas del DataSet. Lo implementan los proveedores de datos de .NET Framework que tienen acceso a los orígenes de datos.
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
Public Interface IDataParameter
public interface IDataParameter
public interface class IDataParameter
type IDataParameter = interface end
El tipo IDataParameter expone los siguientes miembros.

Comentarios
La interfaz IDataParameter permite que una clase heredada implemente una clase Parameter, que representa un parámetro para un objeto Command. Para obtener más información sobre las clases Parameter, vea Configurar parámetros y tipos de datos de parámetros (ADO.NET). Una aplicación no crea una instancia de la interfaz IDataParameter directamente, sino que crea una instancia de una clase que hereda de IDataParameter. Las clases que heredan de IDataParameter deben implementar los miembros heredados y suelen definir miembros adicionales para agregar la funcionalidad específica de proveedor. Por ejemplo, la interfaz IDataParameter define la propiedad DbType. A su vez, la clase OleDbParameter hereda esta propiedad y también define la propiedad OleDbType. Notas para los implementadoresPara potenciar la coherencia entre los proveedores de datos de .NET Framework, asigne a la clase heredada un nombre con el formato Prv Parameter, donde Prv es el prefijo uniforme que se asigna a todas las clases de un espacio de nombres de proveedor de datos de .NET Framework específico. Por ejemplo, Sql es el prefijo de la clase SqlCommand en el espacio de nombres System.Data.SqlClient. Al heredar de la interfaz IDataParameter, se deben implementar los siguientes constructores: Elemento | Descripción |
|---|
PrvParameter() | Inicializa una nueva instancia de la clase Parameter. | PrvParameter(string name, PrvDbType dataType) | Inicializa una nueva instancia de la clase Parameter con el nombre de parámetro y el tipo de datos. | PrvParameter(string name, object value) | Inicializa una nueva instancia de la clase Parameter con el nombre de parámetro y un objeto que es el valor de Parameter. | PrvParameter(string name, PrvDbType dataType, int size) | Inicializa una nueva instancia de la clase Parameter con el nombre de parámetro, el tipo de datos y el ancho. | PrvParameter(string name, PrvDbType dataType, int size, string srcColumn) | Inicializa una nueva instancia de la clase DbParameter con el nombre de parámetro, el tipo de datos, el ancho y el nombre de columna de origen. | PrvParameter(string parameterName, PrvDbType dbType, int size, ParameterDirection direction, Boolean isNullable, Byte precision, Byte scale, string srcColumn, DataRowVersion srcVersion, object value) | Inicializa una nueva instancia de la clase OleDbParameter con el nombre de parámetro, el tipo de datos, el ancho, el nombre de columna de origen, la dirección de parámetros, la precisión numérica y otras propiedades. |

Ejemplos
En el ejemplo siguiente se crean varias instancias de la clase derivada SqlParameter a través de la colección SqlParameterCollection dentro del SqlDataAdapter. Estos parámetros se utilizan para seleccionar datos del origen de datos y colocarlos en DataSet. En este ejemplo se supone que ya se han creado un DataSet y un SqlDataAdapter con el esquema, los comandos y la conexión adecuados.
Public Sub AddSqlParameters()
' ...
' create categoriesDataSet and categoriesAdapter
' ...
categoriesAdapter.SelectCommand.Parameters.Add( _
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters"
categoriesAdapter.SelectCommand.Parameters.Add( _
"@SerialNum", SqlDbType.Int).Value = 239
categoriesAdapter.Fill(categoriesDataSet)
End Sub
public void AddSqlParameters()
{
// ...
// create categoriesDataSet and categoriesAdapter
// ...
categoriesAdapter.SelectCommand.Parameters.Add(
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters";
categoriesAdapter.SelectCommand.Parameters.Add(
"@SerialNum", SqlDbType.Int).Value = 239;
categoriesAdapter.Fill(categoriesDataSet);
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|