System.Data.SqlTypes Namespace

System.Data.SqlTypes 命名空间提供 SQL Server 中本机数据类型的类。 The System.Data.SqlTypes namespace provides classes for native data types in SQL Server. 这些类提供一种比 .NET Framework 公共语言运行时 (CLR) 提供的数据类型更安全、更快的替代方案。 These classes provide a safer, faster alternative to the data types provided by the .NET Framework common language runtime (CLR). 使用此命名空间中的类有助于防止出现精度损失造成的类型转换错误。 Using the classes in this namespace helps prevent type conversion errors caused by loss of precision. 由于其他数据类型在幕后与 SqlTypes 进行相互转换,所以在此命名空间内显式创建和使用对象也会使代码更快。 Because other data types are converted to and from SqlTypes behind the scenes, explicitly creating and using objects within this namespace also yields faster code.

SqlAlreadyFilledException

SqlAlreadyFilledException 类不用作独立组件,而是用作其他类从中派生标准功能的类。The SqlAlreadyFilledException class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

SqlBytes

表示包装 BufferStream 的可变引用类型。Represents a mutable reference type that wraps either a Buffer or a Stream.

SqlChars

SqlChars 是一个可变引用类型,可包装 Char 数组或 SqlString 实例。SqlChars is a mutable reference type that wraps a Char array or a SqlString instance.

SqlFileStream

公开使用 FILESTREAM 列特性作为字节序列存储的 SQL Server 数据。Exposes SQL Server data that is stored with the FILESTREAM column attribute as a sequence of bytes.

SqlNotFilledException

SqlNotFilledException 类不用作独立组件,而是用作其他类从中派生标准功能的类。The SqlNotFilledException class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

SqlNullValueException

Value 结构的 System.Data.SqlTypes 属性设置为 null 时所引发的异常。The exception that is thrown when the Value property of a System.Data.SqlTypes structure is set to null.

SqlTruncateException

在将值设置到 System.Data.SqlTypes 结构中会截断该值时引发的异常。The exception that is thrown when you set a value into a System.Data.SqlTypes structure would truncate that value.

SqlTypeException

System.Data.SqlTypes 的基异常类。The base exception class for the System.Data.SqlTypes.

SqlTypesSchemaImporterExtensionHelper

SqlTypesSchemaImporterExtensionHelper 类不用作独立组件,而是用作其他类从中派生标准功能的类。The SqlTypesSchemaImporterExtensionHelper class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

SqlXml

表示存储在服务器中的或从服务器中检索的 XML 数据。Represents XML data stored in or retrieved from a server.

TypeBigIntSchemaImporterExtension

TypeBigIntSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeBigIntSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeBinarySchemaImporterExtension

TypeBinarySchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeBinarySchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeBitSchemaImporterExtension

TypeBitSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeBitSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeCharSchemaImporterExtension

TypeCharSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeCharSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeDateTimeSchemaImporterExtension

TypeDateTimeSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeDateTimeSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeDecimalSchemaImporterExtension

TypeDecimalSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeDecimalSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeFloatSchemaImporterExtension

TypeFloatSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeFloatSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeIntSchemaImporterExtension

TypeIntSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeIntSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeMoneySchemaImporterExtension

TypeMoneySchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeMoneySchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeNCharSchemaImporterExtension

TypeNCharSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeNCharSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeNTextSchemaImporterExtension

TypeNTextSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeNTextSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeNumericSchemaImporterExtension

TypeNumericSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeNumericSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeNVarCharSchemaImporterExtension

TypeNVarCharSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeNVarCharSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeRealSchemaImporterExtension

TypeRealSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeRealSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeSmallDateTimeSchemaImporterExtension

TypeSmallDateTimeSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeSmallDateTimeSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeSmallIntSchemaImporterExtension

TypeSmallIntSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeSmallIntSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeSmallMoneySchemaImporterExtension

TypeSmallMoneySchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeSmallMoneySchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeTextSchemaImporterExtension

TypeTextSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeTextSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeTinyIntSchemaImporterExtension

TypeTinyIntSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeTinyIntSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeUniqueIdentifierSchemaImporterExtension

TypeUniqueIdentifierSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeUniqueIdentifierSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeVarBinarySchemaImporterExtension

TypeVarBinarySchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeVarBinarySchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeVarCharSchemaImporterExtension

TypeVarCharSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeVarCharSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

TypeVarImageSchemaImporterExtension

TypeVarImageSchemaImporterExtension 类不用作独立组件,而是用作其他类从中派生标准功能的类。The TypeVarImageSchemaImporterExtension class is not intended for use as a stand-alone component, but as a class from which other classes derive standard functionality.

结构

SqlBinary

表示要存储在数据库中或从数据库中检索的二进制数据的可变长度流。Represents a variable-length stream of binary data to be stored in or retrieved from a database.

SqlBoolean

表示要存储在数据库中或者从数据库中检索的整数值,为 1 或 0。Represents an integer value that is either 1 or 0 to be stored in or retrieved from a database.

SqlByte

表示要存储在数据库中或从数据库中检索的 8 位无符号整数,此整数在 0 到 255 范围内。Represents an 8-bit unsigned integer, in the range of 0 through 255, to be stored in or retrieved from a database.

SqlDateTime

表示要存储在数据库中或从数据库中检索的日期和时间数据,值范围介于 1753 年 1 月 1 日到 9999 年 12 月 31 日之间,精度为 3.33 毫秒。Represents the date and time data ranging in value from January 1, 1753 to December 31, 9999 to an accuracy of 3.33 milliseconds to be stored in or retrieved from a database. SqlDateTime 结构具有与其相应的 .NET Framework 类型 DateTime 不同的基础数据类型,该结构可以表示 12:00:00 AM 1/1/0001 和 11:59:59 PM 12/31/9999 之间的任何时间,精度可达到 100 毫微秒。The SqlDateTime structure has a different underlying data structure from its corresponding .NET Framework type, DateTime, which can represent any time between 12:00:00 AM 1/1/0001 and 11:59:59 PM 12/31/9999, to the accuracy of 100 nanoseconds. SqlDateTime 实际上存储的是相对于 00:00:00 AM 1/1/1900 的差值。SqlDateTime actually stores the relative difference to 00:00:00 AM 1/1/1900. 因此,将“00:00:00 AM 1/1/1900”转换为整数将返回 0。Therefore, a conversion from "00:00:00 AM 1/1/1900" to an integer will return 0.

SqlDecimal

表示具有固定精度和小数位数的数值,该数值介于 - 10^38 +1 和 10^38 - 1 之间。Represents a numeric value between - 10^38 +1 and 10^38 - 1, with fixed precision and scale.

SqlDouble

表示要存储在数据库中或从数据库中检索的浮点数字,该数字介于 -1.79E+308 到 1.79E+308 的范围内。Represents a floating-point number within the range of -1.79E +308 through 1.79E +308 to be stored in or retrieved from a database.

SqlGuid

表示要存储在数据库中或要从数据库中检索的 GUID。Represents a GUID to be stored in or retrieved from a database.

SqlInt16

表示要在数据库中存储或检索的 16 位有符号整数。Represents a 16-bit signed integer to be stored in or retrieved from a database.

SqlInt32

表示要在数据库中存储或检索的 32 位有符号整数。Represents a 32-bit signed integer to be stored in or retrieved from a database.

SqlInt64

表示要在数据库中存储或检索的 64 位有符号整数。Represents a 64-bit signed integer to be stored in or retrieved from a database.

SqlMoney

表示要存储在数据库中或要从数据库中检索的货币值,范围介于 -2 63 (或 -922,337,203,685,477.5808) to 2 63 -1 (或 +922,337,203,685,477.5807)之间,精度为千分之十货币单位。Represents 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 currency unit to be stored in or retrieved from a database.

SqlSingle

表示要存储在数据库中或从数据库中检索的浮点数,范围在 -3.40E+38 到 3.40E+38 之间。Represents a floating point number within the range of -3.40E +38 through 3.40E +38 to be stored in or retrieved from a database.

SqlString

表示要存储在数据库中或从数据库中检索的字符的可变长度流。Represents a variable-length stream of characters to be stored in or retrieved from the database. SqlString 具有与其相应的 .NET Framework String 数据类型不同的基础数据结构。SqlString has a different underlying data structure from its corresponding .NET Framework String data type.

接口

INullable

所有 System.Data.SqlTypes 对象和结构均实现 INullable 接口。All the System.Data.SqlTypes objects and structures implement the INullable interface.

枚举

SqlCompareOptions

SqlString 结构指定比较选项值。Specifies the compare option values for a SqlString structure.

StorageState

StorageState 枚举不用作独立组件,而是用作其他类从中派生标准功能的枚举。The StorageState enumeration is not intended for use as a stand-alone component, but as an enumeration from which other classes derive standard functionality.

注解

在每种数据类型SqlTypes SQL Server 中都具有其等效的数据类型具有相同的基础数据表示形式。Each data type in SqlTypes has its equivalent data type in SQL Server, with the same underlying data representation. 其中许多也在 CLR 中具有等效的数据类型。Many of them also have equivalent data types in the CLR. 但是, SqlDateTimeSqlDecimal,并SqlString具有不同的其对应的.NET Framework 数据类型的基础数据结构。However, SqlDateTime, SqlDecimal, and SqlString have different underlying data structures with their corresponding .NET Framework data types.

下表将映射的成员SqlTypes Microsoft SQL Server 数据类型和成员的命名空间SqlDbType枚举。The following table maps the members of the SqlTypes namespace to Microsoft SQL Server data types and to the members of the SqlDbType enumeration.

.NET framework SqlTypes.NET Framework SqlTypes 本机 SQL ServerNative SQL Server .NET Framework SqlDbType.NET Framework SqlDbType
SqlBinary binary、 image、 timestamp、 varbinarybinary, image, timestamp, varbinary 二进制、 图像,时间戳 VarBinaryBinary, Image, TimeStamp, VarBinary
SqlBoolean bit Bit
SqlByte tinyinttinyint TinyIntTinyInt
SqlBytes binary、 image、 timestamp、 varbinarybinary, image, timestamp, varbinary 二进制、 图像,时间戳 VarBinaryBinary, Image, TimeStamp, VarBinary
SqlChars char、 nchar、 文本、 ntext、 nvarchar、 varcharchar, nchar, text, ntext, nvarchar, varchar Char、 NChar、 文本、 Ntext、 NVarChar、 VarCharChar, NChar, Text, Ntext, NVarChar, VarChar
SqlDateTime datetime、 smalldatetimedatetime, smalldatetime DateTime、 SmallDateTimeDateTime, SmallDateTime
SqlDecimal 数字、 十进制numeric, decimal 十进制Decimal
SqlDouble floatfloat FloatFloat
SqlFileStream varbinaryvarbinary VarBinaryVarBinary
SqlGuid uniqueidentifieruniqueidentifier UniqueIdentifierUniqueIdentifier
SqlInt16 smallintsmallint SmallIntSmallInt
SqlInt32 intint IntInt
SqlInt64 bigintbigint BigIntBigInt
SqlMoney money、 smallmoneymoney, smallmoney Money、 SmallMoneyMoney, SmallMoney
SqlSingle 实数real RealReal
SqlString char、 nchar、 文本、 ntext、 nvarchar、 varcharchar, nchar, text, ntext, nvarchar, varchar Char、 NChar、 文本、 Ntext、 NVarChar、 VarCharChar, NChar, Text, Ntext, NVarChar, VarChar
SqlXml xmlxml XmlXml