Comparison of various data types

Source: Internet
Author: User

The type of Parameter is. NET Framework data Provider-specific. If the type is specified, the value is converted to a. NET Framework data provider type before the value of Parameter is passed to the data source. You can also specify the type of Parameter in a general way by setting the DbType property of the Parameter object to a specific DbType.

The. NET Framework Data provider type of the Parameter object is inferred from the. NET Framework type of the Value of the Parameter object, or from the DbType of the Parameter object. The following table shows the Parameter types inferred from an object passed as an Parameter value or a specified DbType.

. NET Framework Types System.Data.DbType SqlDbType OleDbType OdbcType OracleType

bool

Boolean

Bit

Boolean

Bit

Byte

Byte

Byte

TinyInt

Unsignedtinyint

TinyInt

Byte

Byte[]

Binary

VarBinary. If the byte array is larger than the maximum size of VarBinary (8000 bytes), this implicit conversion will fail. For byte arrays larger than 8000 bytes, explicitly set SqlDbType.

VarBinary

Binary

Raw

Char

Inferring SqlDbType from Char is not supported.

Char

Char

Byte

Datetime

Datetime

Datetime

Dbtimestamp

Datetime

Datetime

Decimal

Decimal

Decimal

Decimal

Numeric

Number

Double

Double

Float

Double

Double

Double

Float

Single

Real

Single

Real

Float

Guid

Guid

uniqueidentifier

Guid

uniqueidentifier

Raw

Int16

Int16

SmallInt

SmallInt

SmallInt

Int16

Int32

Int32

Int

Int

Int

Int32

Int64

Int64

Bitint

BigInt

BigInt

Number

Object

Object

Variant

Variant

Inference from Object OdbcType is not supported.

Blob

String

String

NVarChar. If the string is greater than the maximum size of NVarChar (4,000 characters), this implicit conversion will fail. For strings greater than 4,000 characters, explicitly set SqlDbType.

Varwchar

NVarChar

NVarChar

TimeSpan

Time

Inferring SqlDbType from a TimeSpan is not supported.

DBTime

Time

Datetime

UInt16

UInt16

Inferring SqlDbType from UInt16 is not supported.

Unsignedsmallint

Int

UInt16

UInt32

UInt32

Inferring SqlDbType from UInt32 is not supported.

Unsignedint

BigInt

UInt32

UInt64

UInt64

Inferring SqlDbType from UInt64 is not supported.

Unsignedbigint

Numeric

Number

Ansistring

VarChar

VarChar

VarChar

VarChar

Ansistringfixedlength

Char

Char

Char

Char

Currency

Money

Currency

Inferring OdbcType from Currency is not supported.

Number

Date

Inferring SqlType from Date is not supported.

DBDate

Date

Datetime

SByte

Inferring SqlType from SByte is not supported.

TinyInt

Inferring OdbcType from SByte is not supported.

SByte

Stringfixedlength

NChar

WChar

NChar

NChar

Time

Inference from time to SqlType is not supported.

DBTime

Time

Datetime

varnumeric inferred SqlDbType.

varnumeric inferred OdbcType.

Number

Attention

The. NET Framework data provider that is provided with the. NET Framework version 1.0 does not verify that the precision and scale of the decimal parameter values are valid, which can cause truncated data to be inserted into the data source. If you are using the. NET Framework version 1.0, verify that the precision and scale of the decimal value is valid before setting the parameter value. In the. NET Framework version 1.1 and later, an exception is thrown when the Decimal parameter value is set with an invalid precision. However, the number of decimal digits beyond the decimal parameter scale will still be truncated.

Attention

for the. NET Framework 1.0 and later versions, you can use System.Data.SqlTypes for System.Data.SqlClient. For more information, see using SqlTypes.

Comparison of various data types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.