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

OleDbParameter.Precision Property

Gets or sets the maximum number of digits used to represent the Value property.

Namespace:  System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)
public byte Precision { get; set; }

Property Value

Type: System.Byte
The maximum number of digits used to represent the Value property. The default value is 0, which indicates that the data provider sets the precision for Value.

Implements

IDbDataParameter.Precision

The Precision property is only used for decimal and numeric input parameters.

The Precision property should be set only for Decimal and Numeric parameters prior to calling the Prepare method of the OleDbCommand.

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.

The Precision property only affects parameters whose OleDbType is Decimal, Numeric, or VarNumeric. For other data types, Precision is ignored.

NoteNote

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.

NoteNote

.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 Scale 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

[C#]

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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