Breyta

Deila með


OdbcParameter.Precision Property

Definition

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

public:
 property System::Byte Precision { System::Byte get(); void set(System::Byte value); };
public byte Precision { get; set; }
member this.Precision : byte with get, set
Public Property Precision As Byte

Property Value

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

Examples

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

Public Sub CreateOdbcParameter()  
    Dim parameter As New OdbcParameter("Price", OdbcType.Decimal)  
    parameter.Value = 3.1416  
    parameter.Precision = 8  
    parameter.Scale = 4  
End Sub   
public void CreateOdbcParameter()   
 {  
    OdbcParameter parameter = new OdbcParameter("Price", OdbcType.Decimal);  
    parameter.Value = 3.1416;  
    parameter.Precision = 8;  
    parameter.Scale = 4;  
 }  

Remarks

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 OdbcType is Decimal or Numeric. For other data types, Precision is ignored.

Note

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.

Applies to

See also