Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Value Property

IDataParameter.Value Property

Gets or sets the value of the parameter.

[Visual Basic]
Property Value As Object
[C#]
object Value {get; set;}
[C++]
__property Object* get_Value();
__property void set_Value(Object*);
[JScript]
function get Value() : Object;function set Value(Object);

Property Value

An Object that is the value of the parameter. The default value is null.

Remarks

For input parameters, the value is bound to the IDbCommand that is sent to the server. For output and return value parameters, the value is set on completion of the IDbCommand and after the IDataReader is closed.

When sending a null parameter value to the server, the user must specify DBNull, not null. The null value in the system is an empty object that has no value. 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. 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.

The Value property is overwritten by Update.

Example

[Visual Basic, C#, C++] The following example creates an instance of the implementing class, SqlParameter, and sets some of its properties.

[Visual Basic] 
Public Sub CreateSqlParameter()
    Dim myParameter As New SqlParameter("@Description", SqlDbType.VarChar)
    myParameter.Value = "garden hose"
    myParameter.Size = 11
End Sub 'CreateSqlParameter

[C#] 
public void CreateSqlParameter() 
 {
    SqlParameter myParameter = new SqlParameter("@Description", SqlDbType.VarChar);
    myParameter.Value = "garden hose";
    myParameter.Size = 11;
 }

[C++] 
public:
void CreateSqlParameter() 
 {
    SqlParameter* myParameter = new SqlParameter(S"@Description", SqlDbType::VarChar);
    myParameter->Value = S"garden hose";
    myParameter->Size = 11;
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

IDataParameter Interface | IDataParameter Members | System.Data Namespace

Show:
© 2015 Microsoft