DbType DbType DbType DbType Enum

定義

指定 .NET Framework 資料提供者 (Data Provider) 的欄位、屬性或 Parameter 物件的資料型別。Specifies the data type of a field, a property, or a Parameter object of a .NET Framework data provider.

public enum class DbType
public enum DbType
type DbType = 
Public Enum DbType
繼承

欄位

AnsiString AnsiString AnsiString AnsiString 0

非 Unicode 字元的可變長度資料流,範圍在 1 和 8,000 字元之間。A variable-length stream of non-Unicode characters ranging between 1 and 8,000 characters.

AnsiStringFixedLength AnsiStringFixedLength AnsiStringFixedLength AnsiStringFixedLength 22

非 Unicode 字元的固定長度資料流。A fixed-length stream of non-Unicode characters.

Binary Binary Binary Binary 1

二進位資料的可變長度資料流,範圍在 1 和 8,000 位元組之間。A variable-length stream of binary data ranging between 1 and 8,000 bytes.

Boolean Boolean Boolean Boolean 3

表示 truefalse 的布林值的簡單型別。A simple type representing Boolean values of true or false.

Byte Byte Byte Byte 2

值範圍在 0 到 255 之間的 8 位元不帶正負號整數 (Unsigned Integer)。An 8-bit unsigned integer ranging in value from 0 to 255.

Currency Currency Currency Currency 4

貨幣值,範圍從 -2 63 (或 -922,337,203,685,477.5808) 到 2 63 -1 (或 +922,337,203,685,477.5807),正確率為貨幣單位的千分之十。A currency value ranging from -2 63 (or -922,337,203,685,477.5808) to 2 63 -1 (or +922,337,203,685,477.5807) with an accuracy to a ten-thousandth of a currency unit.

Date Date Date Date 5

代表日期值的型別。A type representing a date value.

DateTime DateTime DateTime DateTime 6

表示日期和時間值的型別。A type representing a date and time value.

DateTime2 DateTime2 DateTime2 DateTime2 26

日期和時間資料。Date and time data. 日期值範圍是從西元後 1 年 1 月 1 日到西元後 9999 年 12 月31 日。Date value range is from January 1,1 AD through December 31, 9999 AD. 時間值的範圍從 00:00:00 到 23:59:59.9999999,精確度為 100 奈秒。Time value range is 00:00:00 through 23:59:59.9999999 with an accuracy of 100 nanoseconds.

DateTimeOffset DateTimeOffset DateTimeOffset DateTimeOffset 27

具備時區感知功能的日期和時間資料。Date and time data with time zone awareness. 日期值範圍是從西元後 1 年 1 月 1 日到西元後 9999 年 12 月31 日。Date value range is from January 1,1 AD through December 31, 9999 AD. 時間值的範圍從 00:00:00 到 23:59:59.9999999,精確度為 100 奈秒。Time value range is 00:00:00 through 23:59:59.9999999 with an accuracy of 100 nanoseconds. 時區值範圍從 -14:00 到 +14:00。Time zone value range is -14:00 through +14:00.

Decimal Decimal Decimal Decimal 7

簡單型別,表示具有 28-29 個有效位數、範圍從 1.0 x 10 -28 到大約 7.9 x 10 28 的數值。A simple type representing values ranging from 1.0 x 10 -28 to approximately 7.9 x 10 28 with 28-29 significant digits.

Double Double Double Double 8

浮點型別,表示具有 15-16 位數精確度、範圍從 5.0 x 10 -324 到大約 1.7 x 10 308 的數值。A floating point type representing values ranging from approximately 5.0 x 10 -324 to 1.7 x 10 308 with a precision of 15-16 digits.

Guid Guid Guid Guid 9

全域唯一識別項 (或 GUID)。A globally unique identifier (or GUID).

Int16 Int16 Int16 Int16 10

表示帶正負號的 16 位元整數的整數型別,其值介於 -32768 和 32767 之間。An integral type representing signed 16-bit integers with values between -32768 and 32767.

Int32 Int32 Int32 Int32 11

表示帶正負號的 32 位元整數的整數型別,其值介於 -2147483648 和 2147483647 之間。An integral type representing signed 32-bit integers with values between -2147483648 and 2147483647.

Int64 Int64 Int64 Int64 12

表示帶正負號的 64 位元整數的整數型別,其值介於 -9223372036854775808 和 9223372036854775807 之間。An integral type representing signed 64-bit integers with values between -9223372036854775808 and 9223372036854775807.

Object Object Object Object 13

表示未明確由其他 DbType 值表示的任何參考或實值型別之一般型別。A general type representing any reference or value type not explicitly represented by another DbType value.

SByte SByte SByte SByte 14

表示帶正負號的 8 位元整數的整數型別,其值介於 -128 和 127 之間。An integral type representing signed 8-bit integers with values between -128 and 127.

Single Single Single Single 15

浮點型別,表示具有 7 位數精確度、範圍從 1.5 x 10 -45 到大約 3.4 x 10 38 的數值。A floating point type representing values ranging from approximately 1.5 x 10 -45 to 3.4 x 10 38 with a precision of 7 digits.

String String String String 16

表示 Unicode 字元字串的型別。A type representing Unicode character strings.

StringFixedLength StringFixedLength StringFixedLength StringFixedLength 23

Unicode 字元的固定長度字串。A fixed-length string of Unicode characters.

Time Time Time Time 17

型別,表示 SQL Server DateTime 值。A type representing a SQL Server DateTime value. 如果您想要使用 SQL Server time 值,請使用 TimeIf you want to use a SQL Server time value, use Time.

UInt16 UInt16 UInt16 UInt16 18

表示不帶正負號的 16 位元整數的整數型別,其值介於 0 和 65535 之間。An integral type representing unsigned 16-bit integers with values between 0 and 65535.

UInt32 UInt32 UInt32 UInt32 19

表示不帶正負號的 32 位元整數的整數型別,其值介於 0 和 4294967295 之間。An integral type representing unsigned 32-bit integers with values between 0 and 4294967295.

UInt64 UInt64 UInt64 UInt64 20

表示不帶正負號的 64 位元整數的整數型別,其值介於 0 和 18446744073709551615 之間。An integral type representing unsigned 64-bit integers with values between 0 and 18446744073709551615.

VarNumeric VarNumeric VarNumeric VarNumeric 21

可變長度數值。A variable-length numeric value.

Xml Xml Xml Xml 25

XML 文件或片段的剖析表示。A parsed representation of an XML document or fragment.

備註

參數的類型是 .NET Framework Data Provider 所特有。The type of a parameter is specific to the .NET Framework data provider. 在將值傳遞給資料來源之前Parameter , 指定類型會將的值轉換成資料提供者類型。Specifying the type converts the value of the Parameter to the data provider Type before passing the value to the data source. 如果未指定類型, ADO.NET 會ParameterParameter物件的Value屬性推斷的資料提供者類型。If the type is not specified, ADO.NET infers the data provider Type of the Parameter from the Value property of the Parameter object.

您也可以藉由設定Parameter DbType Parameter物件的屬性, 以一般方式指定的型別。You can also generically specify the type of a Parameter by setting DbType property of a Parameter object.

如果位元組陣列大於8000個位元組, ADO.NET 就無法正確推斷類型。ADO.NET cannot correctly infer the type if a byte array is larger than 8,000 bytes. 使用大於 8000 DbType個位元組的位元組陣列時, 請明確指定。Explicitly specify the DbType when working with byte arrays larger than 8,000 bytes.

適用於

另請參閱