OleDbParameter.Scale 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定被解決的小 Value 數點數。
public:
property System::Byte Scale { System::Byte get(); void set(System::Byte value); };
public byte Scale { get; set; }
[System.Data.DataSysDescription("DbDataParameter_Scale")]
public byte Scale { get; set; }
member this.Scale : byte with get, set
[<System.Data.DataSysDescription("DbDataParameter_Scale")>]
member this.Scale : byte with get, set
Public Property Scale As Byte
屬性值
解決到的小數 Value 點數。 預設值是 0。
實作
- 屬性
範例
以下範例建立 並 OleDbParameter 設定其部分性質。
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;
}
備註
此 Scale 特性僅用於小數與數字輸入參數,然後再呼叫 PrepareOleDbCommand and 的方法來指定數值輸出參數。
將此屬性設定為非資料庫值的值,取決於資料提供者的實作,可能會回傳錯誤碼、截斷或整置資料。
使用 SQL Server Native Client 10(或更新版本)時,若要綁定型別為 Decimal、 Numeric、 VarNumericDBDate、 或 DBTimeStamp的參數,必須手動指定適當的 scale 值。
備註
不支援使用此特性強制傳送至資料庫的資料。 若要在資料傳遞給資料庫前進行Value四周、截斷或其他強制處理,請先使用Math屬於System命名空間的類別,再為參數屬性指派值。
備註
.NET Framework 1.0 版本中包含的資料提供者不會驗證Precision參數值的 Decimal OR Scale 值。 這可能導致截斷資料入資料來源。 如果你使用的是 .NET Framework 1.0 版本,請在設定參數值前驗證 Precision 和 OleDbParameter 的 Decimal 值。 Scale 超過參數尺度的 Decimal 值仍會被截斷。