Export (0) Print
Expand All

OleDbParameter.Precision Property

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

[Visual Basic]
Public Overridable Property Precision As Byte  Implements _
   IDbDataParameter.Precision
[C#]
public virtual byte Precision {get; set;}
[C++]
public: __property virtual unsigned char get_Precision();
public: __property virtual void set_Precision(unsigned char);
[JScript]
public function get Precision() : Byte;
public function set Precision(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

IDbDataParameter.Precision

Remarks

The Precision property is only used for decimal and numeric input parameters. If the value of Precision is less than the actual precision of the parameter value, the behavor may vary depending on the underlying OLE DB provider. Some providers may return an error code, while others may not.

Note   .NET Framework data providers that ship with .NET Framework version 1.0 do not verify the Precision or Scale of Decimal parameter values. This can result in truncated data being 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.

Example

[Visual Basic, C#, C++] The following example creates an OleDbParameter and sets some of its properties.

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

[C#] 
public void CreateOleDbParameter() 
 {
    OleDbParameter myParameter = new OleDbParameter("Price", OleDbType.Decimal);
    myParameter.Value = 3.1416;
    myParameter.Precision = 8;
    myParameter.Scale = 4;
 }

[C++] 
public:
void CreateOleDbParameter() 
 {
    OleDbParameter* myParameter = new OleDbParameter(S"Price", OleDbType::Decimal);
    myParameter->Value = __box(3.1416);
    myParameter->Precision = 8;
    myParameter->Scale = 4;
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OleDbParameter Class | OleDbParameter Members | System.Data.OleDb Namespace | Scale | Size

Show:
© 2014 Microsoft