IDataParameter.Value IDataParameter.Value IDataParameter.Value IDataParameter.Value Property

定义

获取或设置参数的值。Gets or sets the value of the parameter.

public:
 property System::Object ^ Value { System::Object ^ get(); void set(System::Object ^ value); };
public object Value { get; set; }
member this.Value : obj with get, set
Public Property Value As Object

属性值

充当参数值的 ObjectAn Object that is the value of the parameter. 默认值为 null。The default value is null.

示例

下面的示例创建的实现类实例SqlParameter,并设置它的一些属性。The following example creates an instance of the implementing class, SqlParameter, and sets some of its properties.

public void CreateSqlParameter() 
{
    SqlParameter parameter = new SqlParameter(
        "@Description", SqlDbType.VarChar);
    parameter.Value = "garden hose";
    parameter.Size = 11;
}
Public Sub CreateSqlParameter()
    Dim parameter As New SqlParameter( _
        "@Description", SqlDbType.VarChar)
    parameter.Value = "garden hose"
    parameter.Size = 11
End Sub 

注解

用于输入参数的值绑定到IDbCommand,发送到服务器。For input parameters, the value is bound to the IDbCommand that is sent to the server. 对于输出参数和返回值参数,该数值将在完成IDbCommand前后IDataReader已关闭。For output and return value parameters, the value is set on completion of the IDbCommand and after the IDataReader is closed.

如果向服务器发送 null 参数值,用户必须指定DBNull,而不是 null。When sending a null parameter value to the server, the user must specify DBNull, not null. 系统中的 null 值是一个不具有任何值的空对象。The null value in the system is an empty object that has no value. DBNull 用于表示 null 值。DBNull is used to represent null values.

如果应用程序指定的数据库类型,绑定的值转换为该类型时提供程序将数据发送到服务器。If the application specifies the database type, the bound value is converted to that type when the provider sends the data to the server. 提供程序尝试将转换任何类型的值,如果它支持IConvertible接口。The provider attempts to convert any type of value if it supports the IConvertible interface. 如果指定的类型不兼容的值,可能会导致转换错误。Conversion errors may result if the specified type is not compatible with the value.

Value属性会被覆盖UpdateThe Value property is overwritten by Update.

适用于