OleDbParameter.Scale Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.


Gets or sets the number of decimal places to which Value is resolved.

Namespace:   System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)

abstract Scale : byte with get, set
override Scale : byte with get, set

Property Value

Type: System.Byte

The number of decimal places to which Value is resolved. The default is 0.

The Scale property is only used for decimal and numeric input parameters before calling the Prepare method of the OleDbCommand and to specify numeric output parameters.

Setting this property to a value other than the value in the database depends on the implementation of the data provider and may return an error code, truncate, or round data.

When using SQL Server Native Client 10 (or later), to bind a parameter whose type is Decimal, Numeric,VarNumeric, DBDate, or DBTimeStamp, you must manually specify an appropriate scale value.


Use of this property to coerce data passed to the database is not supported. To round, truncate, or otherwise coerce data before passing it to the database, use the Math class that is part of the System namespace prior to assigning a value to the parameter's Value property.


.NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the Precision or Scale of Decimal parameter values. This can cause truncated data to be inserted at the data source. If you are using .NET Framework version 1.0, validate the Precision and OleDbParameter of Decimal values before setting the parameter value. Scale values that exceed the Decimal parameter scale are still truncated.

The following example creates an OleDbParameter and sets some of its properties.

[Visual Basic]

Public Sub CreateOleDbParameter()
    Dim parameter As New OleDbParameter("Price", OleDbType.Decimal)
    parameter.Value = 3.1416
    parameter.Precision = 8
    parameter.Scale = 4
End Sub 'CreateOleDbParameter


public void CreateOleDbParameter() 
    OleDbParameter parameter = new OleDbParameter("Price", OleDbType.Decimal);
    parameter.Value = 3.1416;
    parameter.Precision = 8;
    parameter.Scale = 4;

.NET Framework
Available since 1.1
Return to top