SQL Server与ADO.Net数据类型对照

下表显示了 .NET Framework 类型、DbType 和 SqlDbType 枚举以及 SqlDataReader 的访问器方法。
SQL Server 数据库引擎类型.NET Framework 类型SqlDbType 枚举SqlDataReader SqlTypes 类型化访问器DbType 枚举SqlDataReader DbType 类型化访问器
bigint Int64 BigInt GetSqlInt64 Int64 GetInt64
binary Byte[] VarBinary GetSqlBinary Binary GetBytes
bit Boolean Bit GetSqlBoolean Boolean GetBoolean
char String Char GetSqlString AnsiStringFixedLength, GetString
Char[] String GetChars
date
(仅适用 SQL Server 2008)
DateTime Date GetSqlDateTime Date GetDateTime
datetime DateTime DateTime GetSqlDateTime DateTime GetDateTime
datetime2
(仅适用 SQL Server 2008)
DateTime2 DateTime2 GetSqlDateTime DateTime2 GetDateTime
datetimeoffset
(仅适用 SQL Server 2008)
DateTimeOffset DateTimeOffset DateTimeOffset GetDateTimeOffset
decimal Decimal Decimal GetSqlDecimal Decimal GetDecimal
FILESTREAM 属性 (varbinary(max) Byte[] VarBinary GetSqlBytes Binary GetBytes
float Double Float GetSqlDouble Double GetDouble
image Byte[] Binary GetSqlBinary Binary GetBytes
int Int32 Int GetSqlInt32 Int32 GetInt32
money Decimal Money GetSqlMoney Decimal GetDecimal
nchar String NChar GetSqlString StringFixedLength GetString
Char[] GetChars
ntext String NText GetSqlString String GetString
Char[] GetChars
numeric Decimal Decimal GetSqlDecimal Decimal GetDecimal
nvarchar String NVarChar GetSqlString String GetString
Char[] GetChars
real Single Real GetSqlSingle Single GetFloat
rowversion Byte[] Timestamp GetSqlBinary Binary GetBytes
smalldatetime DateTime DateTime GetSqlDateTime DateTime GetDateTime
smallint Int16 SmallInt GetSqlInt16 Int16 GetInt16
smallmoney Decimal SmallMoney GetSqlDecimal Decimal GetDecimal
sql_variant Object* Variant GetSqlValue * Object GetValue *
text String Text GetSqlString String GetString
Char[] GetChars
time
(仅适用 SQL Server 2008)
TimeSpan Time Time GetDateTime
timestamp Byte[] Timestamp GetSqlBinary Binary GetBytes
tinyint Byte TinyInt GetSqlByte Byte GetByte
uniqueidentifier Guid UniqueIdentifier GetSqlGuid Guid GetGuid
varbinary Byte[] VarBinary GetSqlBinary Binary GetBytes
varchar String VarChar GetSqlString AnsiString, String GetString
Char[] GetChars
xml Xml Xml GetSqlXml Xml

 

posted @ 2011-03-17 14:53  凌鸢  阅读(2371)  评论(1编辑  收藏  举报