Export (0) Print
Expand All

OdbcParameter.Precision Property

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

Namespace:  System.Data.Odbc
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

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.

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.

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft