SqlServer與.NET的資料型別對映關係圖(轉)

iSQlServer發表於2010-05-21

做個記錄..省的以後找的麻煩啦..

關係表

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

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16436858/viewspace-663357/,如需轉載,請註明出處,否則將追究法律責任。

相關文章