Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

OdbcParameter.Value Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

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 OdbcCommand that is sent to the server. For output and return-value parameters, the value is set on completion of the OdbcCommand and after the OdbcDataReader is closed.

When sending a null parameter value to the server, the user must specify DBNull, not null. A null value in the system is an empty object that has no value. DBNull is used to represent null values. If the parameter is used to call a stored procedure with parameters that have default values, setting Value to null causes the default value to be used.

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 OdbcType properties can be inferred by setting Value. If applicable, the size, precision and scale will also be inferred from Value when the parameterized statement is executed. Inferred values, however, will not be exposed to the user.

The Value property is overwritten by the Update method.

Example

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

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

[C#] 
public void CreateOdbcParameter() 
 {
    OdbcParameter myParameter = new OdbcParameter("Description", OdbcType.VarChar, 88);
    myParameter.Value = "garden hose";
 }

[C++] 
public:
    void CreateOdbcParameter()
    {
        OdbcParameter* myParameter = new OdbcParameter(S"Description", OdbcType::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

OdbcParameter Class | OdbcParameter Members | System.Data.Odbc Namespace | OdbcType | DbType

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.