Share via


SqlParameter.SqlValue Property

Definition

Gets or sets the value of the parameter as an SQL type.

public:
 property System::Object ^ SqlValue { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.Browsable(false)]
public object SqlValue { get; set; }
public object SqlValue { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SqlValue : obj with get, set
member this.SqlValue : obj with get, set
Public Property SqlValue As Object

Property Value

An Object that is the value of the parameter, using SQL types. The default value is null.

Attributes

Remarks

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

This property can be set to null or DBNull.Value. Use DBNull.Value to send a NULL value as the value of the parameter. Use null or do not set SqlParameter.SqlValue to use the default value for the parameter.

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 tries 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 SqlDbType properties can be inferred by setting the SqlParameter.Value.

The SqlParameter.Value property is overwritten by SqlDataAdapter.UpdateCommand.

Use the SqlParameter.Value property to return parameter values as common language runtime (CLR) types.

For information about streaming, see SqlClient Streaming Support.

Applies to