SqlServer与.NET的数据类型映射关系图
做个记录..省的以后找的麻烦啦..
关系表
SQL Server 数据库引擎类型 |
.NET Framework 类型 |
SqlDbType 枚举 |
SqlDataReader SqlTypes 类型化访问器 |
DbType 枚举 |
SqlDataReader DbType 类型化访问器 |
---|---|---|---|---|---|
bigint |
Int64 |
||||
binary |
Byte[] |
||||
bit |
Boolean |
||||
char |
String Char[] |
||||
date (仅适用 SQL Server 2008) |
DateTime |
||||
datetime |
DateTime |
||||
datetime2 (仅适用 SQL Server 2008) |
DateTime2 |
||||
datetimeoffset (仅适用 SQL Server 2008) |
DateTimeOffset |
none |
|||
decimal |
Decimal |
||||
FILESTREAM 属性 (varbinary(max) |
Byte[] |
||||
float |
Double |
||||
image |
Byte[] |
||||
int |
Int32 |
||||
money |
Decimal |
||||
nchar |
String Char[] |
||||
ntext |
String Char[] |
||||
numeric |
Decimal |
||||
nvarchar |
String Char[] |
||||
real |
Single |
||||
rowversion |
Byte[] |
||||
smalldatetime |
DateTime |
||||
smallint |
Int16 |
||||
smallmoney |
Decimal |
||||
sql_variant |
Object* |
GetValue * |
|||
text |
String Char[] |
||||
time (仅适用 SQL Server 2008) |
TimeSpan |
none |
|||
timestamp |
Byte[] |
||||
tinyint |
Byte |
||||
uniqueidentifier |
Guid |
||||
varbinary |
Byte[] |
||||
varchar |
String Char[] |
||||
xml |
Xml |
none |
摘自:http://msdn.microsoft.com/zh-cn/library/cc716729(VS.90).aspx