OdbcParameter.Scale プロパティ
定義
public:
property System::Byte Scale { System::Byte get(); void set(System::Byte value); };
public byte Scale { get; set; }
member this.Scale : byte with get, set
Public Property Scale As Byte
プロパティ値
Value の解決先の小数点以下桁数です。The number of decimal places to which Value is resolved. 既定値は 0 です。The default is 0.
実装
例
次の例では、を作成 OdbcParameter し、そのプロパティの一部を設定します。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;
}
注釈
Scaleプロパティは、10進数と数値の入力パラメーターにのみ使用されます。The Scale property is used only for decimal and numeric input parameters.
このプロパティをデータベースの値以外の値に設定した場合の効果は、データプロバイダーの実装によって異なります。また、エラーコードを返すか、データの切り捨てやラウンドを行うことができます。The effect of 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, or truncate or round data.
プロパティは、 Scale OdbcType がまたはであるパラメーターにのみ影響し Decimal
Numeric
ます。The Scale property only affects parameters whose OdbcType is Decimal
or Numeric
. その他のデータ型の場合、 Scale は無視されます。For other data types, Scale is ignored.
SQL Server Native Client 10 (またはそれ以降) を使用して、型が Decimal、Numeric、VarNumeric、DBDate、または Dbdate であるパラメーターをバインドする場合は、適切なスケール値を手動で指定する必要があります。When using SQL Server Native Client 10 (or later) to bind a parameter whose type is Decimal, Numeric, VarNumeric, DBDate, or DBTimeStamp, you must manually specify an appropriate Scale value.
注意
このプロパティを使用して、データベースに渡されるデータを強制的に変換することはできません。Use of this property to coerce data passed to the database is not supported. データベースに渡す前にデータを丸め、切り捨て、または強制するには、 Math System
パラメーターのプロパティに値を割り当てる前に、名前空間の一部であるクラスを使用し Value
ます。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.
注意
.NET Framework バージョン1.0 に含まれている .NET Framework データプロバイダーは、 scale
パラメーター値のを検証しません Decimal 。.NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the scale
of Decimal parameter values. これにより、変更されたデータがデータソースに挿入される可能性があります。This can cause modified data being inserted at the data source. .NET Framework バージョン1.0 を使用している場合は scale
、 decimal
パラメーター値を設定する前に、値のを検証してください。If you are using .NET Framework version 1.0, validate the scale
of decimal
values before setting the parameter value. .NET Framework バージョン1.1 以降のバージョンを使用する場合、 scale
パラメーターの小数点以下桁数を超える値 decimal
は、基になる ODBC ドライバーの動作である場合にのみ、小数点以下桁数が切り捨てられます。When you use .NET Framework version 1.1 or later versions, scale
values that exceed the decimal
parameter scale might only be truncated in scale, if that is the behavior of the underlying ODBC driver.