ADO数据类型在各数据库及.net框架中的对应值关系

ADO数据类型在各数据库及.net框架中的对应值关系

一、 对于做有数据库的网站来说:如果你用的是sql数据库,那就用sqlClient数据连接方式,不要用oleDb方式,易出错。

二、Access的字段类型问题,Access的字段类型与OleDbType的类型很难一一吻合,
      那么取相似的即可,比如access中的备注型,那么就在OleDbType中用
       LongVarchar即可。比如:

    OleDbParameter para=new OleDbParameter("@proFun",OleDbType.LongVarChar);
    para.Value=myaddPro.proFun;//一个产品对象的功能描叙参数,备注型
    cmd.Parameters.Add(para);

三、System.Data.OleDb.OleDbType.LongVarBinary对应SQL数据库的类型为image.


=====================================================================================

ADO数据类型在各数据库及.net框架中的对应值关系

下面就是ADO数据类型在 Visual Basic, Access, SQL Server, Oracle, 和 .NET Framework之间的转换关系对照表。

 

ADODataTypeEnum

ADODataTypeEnumValue

.NETFramework

SQLServer

扫描二维码关注公众号,回复: 4917697 查看本文章

Size

Access

Oracle

VisualBasic6.0

adBigInt

20

Int64
SqlDbType.BigInt 10
11OleDbType.BigInt

bigint 9

8

 

 

Variant

adBinary

128

Byte[]
SqlDbType.VarBinary 10
11OleDbType.Binary

binary
timestamp

50
8

 

Raw 7

Variant

adBoolean

11

Boolean
SqlDbType.Bit 1011
OleDbType.Boolean

bit


1
2

  
  
YesNo

 

Boolean

adBSTR

8

String
OleDbType.BSTR 11

 

 

 

 

 

adChapter

136

(DataReader)

 

 

 

 

 

adChar

129

String 
SqlDbType.Char 10
11OleDbType.Char

char

X

 

Char

String

adCurrency

6

Decimal
SqlDbType.Money 10
OleDbType.Currency 
11

money
smallmoney
 

8
4
0

  
  
Currency

 

Currency

adDate

7

DateTime
OleDbType.DBDate 11

 


0

 
DateTime 2

 

Date

adDBDate

133

DateTime
OleDbType.DBDate 11

 

 

 

 

 

adDBFileTime

137

DBFileTime 11

 

 

 

 

 

adDBTime

134

DateTime
OleDbType.DBTime 11

 

 

 

 

 

adDBTimeStamp

135

DateTime
SqlDbType.DateTime 10
11OleDbType.DBTimeStamp

datetime
 smalldatetime
 

8
4
0

 
 
DateTime 1

Date

Date

adDecimal

14

Decimal
OleDbType.Decimal 11

 

 

 

Decimal 7

Variant 6

adDouble

5

Double
SqlDbType.Float 10
11OleDbType.Double

float

 
8
0

 
 
Double

Float

Double

adEmpty

0

Empty 11

 

 

 

 

 

adError

10

External-Exception
OleDbType.Error 11

 

 

 

 

 

adFileTime

64

DateTime
OleDbType.Filetime 11

 

 

 

 

 

adGUID

72

Guid 
SqlDbType.UniqueIdentifier 10
11OleDbType.Guid

uniqueidentifier5

16

 
 
ReplicationID2,3 

 

Variant

adIDispatch

9

Object
OleDbType.IDispatch 11

 

 

 

 

 

adInteger

3

Int32
SqlDbType.Int 10
11OleDbType.Integer

identity 4
int
 

4
4
 

  
AutoNumber
Long Integer

Int 7

Long

adIUnknown

13

Object
OleDbType.IUnknown 11

 

 

 

 

 

adLongVarBinary

205

Byte[]
SqlDbType.VarBinary 10
11OleDbType.LongVarBinary

image

2147483647

 
 
OLEObject

Long Raw 7
8Blob

Variant

adLongVarChar

201

String
SqlDbType.VarChar 10
11OleDbType.LongVarChar

text

2147483647

 
Memo 1, 22
Hyperlink 1,

Long 7
8Clob

String

adLongVarWChar

203

String
SqlDbType.NText10
OleDbType.VarWChar 
11

ntext 5

1073741823

 
Memo 33
Hyperlink

NClob 8

String

adNumeric

131

Decimal
SqlDbType.Decimal 10
11OleDbType.Decimal

decimal
numeric
 

9
 

 
 
Decimal 3

Decimal
Integer
Number
SmallInt

Variant 6

adPropVariant

138

Object
OleDbType.PropVariant 11

 

 

 

 

 

adSingle

4

Single
SqlDbType.Real 10
11OleDbType.Single

real

4

 
 
Single

 

Single

adSmallInt

2

Int16,
SqlDbType.SmallInt 10
11OleDbType.SmallInt

smallInt

2

 
 
Integer

 

Integer

adTinyInt

16

Byte
OleDbType.TinyInt 11

 

 

 

 

 

adUnsignedBigInt

21

UInt64
OleDbType.UnsignedBigInt 11

 

 

 

 

 

adUnsignedInt

19

UInt32
OleDbType.UnsignedInt 11

 

 

 

 

 

adUnsignedSmallInt

18

UInt16
OleDbType.UnsignedSmallInt 11

 

 

 

 

 

adUnsignedTinyInt

17

Byte
SqlDbType.TinyInt 10
11OleDbType.UnsignedTinyInt

tinyInt

1

 
 
Byte

 

Byte

adUserDefined

132

 

 

 

 

 

 

adVarBinary

204

Byte[] 
SqlDbType.VarBinary 10
11OleDbType.VarBinary

varbinary

50

 
 
ReplicationID 1

 

Variant

adVarChar

200

String
SqlDbType.VarChar 10
11OleDbType.VarChar

varchar

X

 
 
Text 1, 2

VarChar

String

adVariant

12

Object
SqlDbType.Variant 1011
OleDbType.Variant

sql_variant 9

8016

 

VarChar2

Variant

adVarNumeric

139

OleDbType.VarNumeric 11

 

 

 

 

 

adVarWChar

202

String
SqlDbType.NVarChar 10
11OleDbType.VarWChar

nvarchar 5

X

 
 
Text 3

NVarChar2

String

adWChar

130

String
SqlDbType.NChar 10
11OleDbType.WChar

nchar 5

X

 

 

String

 

1 - ODBC Driver (3.51.171300):  Microsoft Access Driver (*.mdb),    Access 97 (3.5 format) 
2 - OLE DB Provider: Microsoft.Jet.OLEDB.3.51,   Access 97 (3.5 format)  
3 - OLE DB Provider: Microsoft.Jet.OLEDB.4.0 ,   Access 2000 (4.0 format) 
4 - OLE DB Provider: SQLOLEDB,   SQL Server 6.5 
5 - OLE DB Provider: SQLOLEDB,   SQL Server 7.0 +
6 - The VB Decimal data type can only be used within a Variant, that is, you cannot declare
     a VB variable to be of type Decimal. 
7 - Oracle 8.0.x   Note: DECIMAL and INT are synonyms for NUMBER and NUMBER(10) respectively.
8 - Oracle 8.1.x 
9 - OLE DB Provider: SQLOLEDB, SQL Server 2000 +
10 - SQL Server .NET Data Provider (via System.Data.SqlTypes)
11 - OLE DB .NET Data Provider (via System.Data.OleDb)

猜你喜欢

转载自blog.csdn.net/hljqfl/article/details/86318470