This documentation is archived and is not being maintained.

OleDbParameter.Value Property

Gets or sets the value of the parameter.

[Visual Basic]
Public Overridable Property Value As Object  Implements _
   IDataParameter.Value
[C#]
public virtual object Value {get; set;}
[C++]
public: __property virtual Object* get_Value();
public: __property virtual void set_Value(Object*);
[JScript]
public function get Value() : Object;
public function set Value(Object);

Property Value

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

Implements

IDataParameter.Value

Remarks

For input parameters, the value is bound to the OleDbCommand that is sent to the server. For output and return value parameters, the value is set on completion of the OleDbCommand and after the OleDbDataReader 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.

Both the DbType and OleDbType properties can be inferred by setting the Value.

The Value property is overwritten by Update.

Example

[Visual Basic, C#, C++] The following example creates an OleDbParameter and sets some of its properties.

[Visual Basic] 
Public Sub CreateOleDbParameter()
    Dim myParameter As New OleDbParameter("Description", OleDbType.VarChar, 88)
    myParameter.Value = "garden hose"
End Sub 'CreateOleDbParameter

[C#] 
public void CreateOleDbParameter() 
 {
    OleDbParameter myParameter = new OleDbParameter("Description", OleDbType.VarChar, 88);
    myParameter.Value = "garden hose";
 }

[C++] 
public:
void CreateOleDbParameter() 
 {
    OleDbParameter* myParameter = new OleDbParameter(S"Description", OleDbType::VarChar, 88);
    myParameter->Value = S"garden hose";
 }

[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

See Also

OleDbParameter Class | OleDbParameter Members | System.Data.OleDb Namespace | OleDbType | DbType

Show: