托管数据类型映射 (SQL Server Compact)

Microsoft SQL Server Compact 4.0 不完全支持所有的 .NET 数据类型;当使用 ADO.NET 访问数据时,SQL Server Compact 4.0 必须将不支持的类型转换为所支持的类型。

数据类型映射

下表列出了 SQL Server Compact 4.0 和 .NET 数据访问接口之间的数据类型映射:

.NET 数据类型

SQL Server Compact 数据类型

binary

varbinary

boolean

bit

byte

tinyint

byte[]

varbinary

datetime

datetime

decimal

numeric

double

float

guid

uniqueidentifier

image

image

int16

smallint

int32

int

int64

bigint

SqlBinary

varbinary

SqlBoolean

bit

SqlByte

tinyint

SqlDecimal¹

numeric

SqlDateTime

datetime

SqlDouble

float

SqlGuid

uniqueidentifier

SqlInt16

smallint

SqlInt32

int

SqlInt64

bigint

SqlMoney

money

SqlSingle

real

SqlString

nvarchar

single

real

string

nvarchar

¹ SQL Server Compact 4.0 支持的 SqlDecimal 数据类型只能达到 96 位。如果超过 96 位,SQL Server Compact 将引发溢出异常错误。

请参阅

参考

数据类型

其他资源

生成托管应用程序 (SQL Server Compact)