SQL Server 和 .NET Framework 基于不同的类型系统。  例如,.NET Framework Decimal 结构的最大小数位数为 28,而 SQL Server 的 decimal 和 numeric 数据类型的最大小数位数为 38。  为了在读取和写入数据时维护数据的完整性,SqlDataReader 将公开用于返回 System.Data.SqlTypes 的对象的 SQL Server 特定的类型化访问器方法以及用于返回 .NET Framework 类型的访问器方法。  SQL Server 类型和 .NET Framework 类型也可通过 DbTypeSqlDbType 类中的枚举表示,当您指定 SqlParameter 数据类型时可以使用这些枚举。

下表显示推断的 .NET Framework 类型、DbTypeSqlDbType 枚举以及 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[]

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 及更高版本)

DateTime

DateTime2

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

图像

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

数值

Decimal

Decimal

GetSqlDecimal

Decimal

GetDecimal

nvarchar

String

Char[]

NVarChar

GetSqlString

String

GetString

GetChars

实数

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

GetSqlMoney

Decimal

GetDecimal

sql_variant

Object*

Variant

GetSqlValue *

Object

GetValue *

文本

String

Char[]

Text

GetSqlString

String

GetString

GetChars

时间

(SQL Server 2008 及更高版本)

TimeSpan

Time

Time

GetDateTime

时间戳

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

SQL Server 数据类型与.Net Framework平台映射的更多相关文章

  1. SQL Server 数据类型映射 (ADO.NET)

    SQL Server 数据类型映射 (ADO.NET) .NET Framework 3.5 更新:November 2007 SQL Server 和 .NET Framework 基于不同的类型系 ...

  2. SQL Server 数据类型映射(转载)

    SQL Server 数据类型映射 SQL Server 和 .NET Framework 基于不同的类型系统. 例如,.NET Framework Decimal 结构的最大小数位数为 28,而 S ...

  3. (转)SQL Server 数据类型映射

    SQL Server 数据类型映射 SQL Server 和 .NET Framework 基于不同的类型系统. 例如,.NET Framework Decimal 结构的最大小数位数为 28,而 S ...

  4. SQL Server 数据类型映射

    SQL Server 和 .NET Framework 基于不同的类型系统. 例如,.NET Framework Decimal 结构的最大小数位数为 28,而 SQL Server 的 decima ...

  5. SQL Server游标 C# DataTable.Select() 筛选数据 什么是SQL游标? SQL Server数据类型转换方法 LinQ是什么? SQL Server 分页方法汇总

    SQL Server游标   转载自:http://www.cnblogs.com/knowledgesea/p/3699851.html. 什么是游标 结果集,结果集就是select查询之后返回的所 ...

  6. 为更好地设计数据库,重新整理sql server数据类型

    我们在平常开发过程中,在设计数据的时候,经常碰到数据类型选择的问题,为了更快,更合适地选择正确的数据类型,所以在这里做个总结. 分类 sql server 数据类型 c# 数据类型 描述 应用场景 字 ...

  7. MySql和SQL Server数据类型 对比

    My Sql 数据类型 SQL Server 数据类型 Yes/No bit Smallint(字节型) tinyint Integer(长整型) int Real(单精度浮点型)    real F ...

  8. SQL Server数据类型与SDE库表sde_type对照表

    SDE_column_registry 表管理所有注册列. 警告:如果使用 SQL 界面更改列定义,SDE_column_registry 表中的记录将不会更新.这可能导致之后的任何数据导出失败. S ...

  9. SQL Server数据类型

    转载:http://www.ezloo.com/2008/10/sql_server_data_type.html    数据类型是数据的一种属性,是数据所表示信息的类型.任何一种语言都有它自己所固有 ...

随机推荐

  1. JAVA爬取亚马逊的商品信息

    在程序里面输入你想爬取的商品名字,就可以返回这件商品在亚马逊搜索中都所有相关商品的信息,包括名字和价格. 解决了在爬取亚马逊时候,亚马逊可以识别出你的爬虫,并返回503,造成只能爬取几个页面的问题. ...

  2. love 玫瑰花

    <!doctype html> <html> <head> <title>Love</title> <meta charset=&qu ...

  3. jenkins 学习记录2

    主题 在之前的学习中(http://www.cnblogs.com/abcwt112/p/6274575.html)我已经学会怎么打包了..这篇文章记录分享我学习如何利用jenkins将打完的包发布到 ...

  4. MySql 之 FIND_IN_SET 和IN

    CREATE TABLE `test` (   `id` int(8) NOT NULL auto_increment,   `name` varchar(255) NOT NULL,   `list ...

  5. jmap, jhat命令

    jmap命令有下面几种常用的用法 jmap [pid] jmap -histo:live [pid] >a.log jmap -dump:live,format=b,file=xxx.xxx [ ...

  6. box-shadow 内阴影

    1.盒子阴影样式单词:box-shadow 2.语法 代表边框间距靠左0 靠上0 和1px阴影范围 阴影颜色为黑色(#000),有inset 代表框内阴影 ,不带inset 代表框外阴影. 注意:bo ...

  7. 551. Student Attendance Record I 从字符串判断学生考勤

    [抄题]: You are given a string representing an attendance record for a student. The record only contai ...

  8. java面试题 级hr解答 非技术问题 !=!=未看

    Java基础 ● 集合类以及集合框架:HashMap与HashTable实现原理,线程安全性,hash冲突及处理算法:ConcurrentHashMap: ● 进程和线程的区别: ● Java的并发. ...

  9. PCL点云库中的坐标系(CoordinateSystem)

    博客转载自:https://blog.csdn.net/qq_33624918/article/details/80488590 引言 世上本没有坐标系,用的人多了,便定义了坐标系统用来定位.地理坐标 ...

  10. Hyperledger Fabric开发

    打开Hyperledger Fabric在线开发文档:https://hyperledger-fabric.readthedocs.io 建议在Mac或Linux环境下操作,因为文档基本上是按照Mac ...