SqlServer与.NET的数据类型映射关系图
关系表
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[] | Char | GetSqlString | AnsiStringFixedLength, String | GetString 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 | none | 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 Char[] | NChar | GetSqlString | StringFixedLength | GetString GetChars |
ntext | String Char[] | NText | GetSqlString | String | GetString GetChars |
numeric | Decimal | Decimal | GetSqlDecimal | Decimal | GetDecimal |
nvarchar | String Char[] | NVarChar | GetSqlString | String | GetString 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 Char[] | Text | GetSqlString | String | GetString GetChars |
time (仅适用 SQL Server 2008) | TimeSpan | Time | none | 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 Char[] | VarChar | GetSqlString | AnsiString, String | GetString GetChars |
xml | Xml | Xml | GetSqlXml | Xml | none |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2017-09-01 MVC Post 提交表单 允许他提交参数包含html标记的解决方法