ADO Type 屬性
❮ 完整的欄位物件參考
Type 屬性設定或返回一個 DataTypeEnum 值,該值指示 Parameter、Field 或 Property 物件的型別。
物件 | Type 屬性說明 |
---|---|
引數 | Type 屬性對 Parameter 物件具有讀/寫許可權。 |
欄位 | Type 屬性是讀/寫屬性,有一個例外;對於新增到 Record 的 Fields 集合的新 Field 物件,在 Value 屬性被設定之前以及在提供程式呼叫 Fields 集合的 Update 方法之前,此屬性是隻讀的。 |
屬性 | Type 屬性對 Property 物件是隻讀的。 |
語法
objectname.Type
示例 - 對於 Field 物件
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "Select * from orders", conn
response.write(rs.Fields(0).Type)
rs.Close
conn.close
%>
示例 - 用於 Parameter 物件
<%
set comm=Server.CreateObject("ADODB.Command")
set para=Server.CreateObject("ADODB.Parameter")
para.Type=adVarChar
para.Size=25
para.Direction=adParamInput
para.Value=varfname
comm.Parameters.Append para
%>
示例 - 對於 Property 物件
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "Select * from orders", conn
set prop=Server.CreateObject("ADODB.Property")
'顯示 Orders 表的屬性屬性
for each prop in rs.Properties
response.write("Attr:" & prop.Attributes & "<br>")
response.write("Name:" & prop.Name & "<br>")
response.write("Value:" & prop.Value & "<br>")
next
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
DataTypeEnum 值
指定 Field、Parameter 或 Property 物件的的資料型別。
常量 | 值 | 描述 |
---|---|---|
adEmpty | 0 | 無返回值 |
adSmallInt | 2 | 一個 2 位元組的有符號整數。 |
adInteger | 3 | 一個 4 位元組的有符號整數。 |
adSingle | 4 | 一個單精度浮點值。 |
adDouble | 5 | 一個雙精度浮點值。 |
adCurrency | 6 | 一個貨幣值。 |
adDate | 7 | 自 1899 年 12 月 30 日以來的天數 + 一天的分數。 |
adBSTR | 8 | 一個以 null 結尾的字元字串。 |
adIDispatch | 9 | 指向 COM 物件上的 IDispatch 介面的指標。注意:目前 ADO 不支援。 |
adError | 10 | 一個 32 位錯誤程式碼。 |
adBoolean | 11 | 一個布林值。 |
adVariant | 12 | 一個 Automation Variant。注意:目前 ADO 不支援。 |
adIUnknown | 13 | 指向 COM 物件上的 IUnknown 介面的指標。注意:目前 ADO 不支援。 |
adDecimal | 14 | 具有固定精度和小數位數的精確數值。 |
adTinyInt | 16 | 一個 1 位元組的有符號整數。 |
adUnsignedTinyInt | 17 | 一個 1 位元組的無符號整數。 |
adUnsignedSmallInt | 18 | 一個 2 位元組的無符號整數。 |
adUnsignedInt | 19 | 一個 4 位元組的無符號整數。 |
adBigInt | 20 | 一個 8 位元組的有符號整數。 |
adUnsignedBigInt | 21 | 一個 8 位元組的無符號整數。 |
adFileTime | 64 | 自 1601 年 1 月 1 日以來的 100 納秒間隔數。 |
adGUID | 72 | 一個全域性唯一識別符號 (GUID)。 |
adBinary | 128 | 一個二進位制值。 |
adChar | 129 | 一個字串值。 |
adWChar | 130 | 一個以 null 結尾的 Unicode 字元字串。 |
adNumeric | 131 | 具有固定精度和小數位數的精確數值。 |
adUserDefined | 132 | 一個使用者定義的變數。 |
adDBDate | 133 | 一個日期值 (yyyymmdd)。 |
adDBTime | 134 | 一個時間值 (hhmmss)。 |
adDBTimeStamp | 135 | 一個日期/時間戳 (yyyymmddhhmmss 加上十億分之一的秒數)。 |
adChapter | 136 | 一個 4 位元組的 chapter 值,用於標識子行集中的行。 |
adPropVariant | 138 | 一個 Automation PROPVARIANT。 |
adVarNumeric | 139 | 一個數值 (僅用於 Parameter 物件)。 |
adVarChar | 200 | 一個字串值 (僅用於 Parameter 物件)。 |
adLongVarChar | 201 | 一個長字串值。 |
adVarWChar | 202 | 一個以 null 結尾的 Unicode 字元字串。 |
adLongVarWChar | 203 | 一個長的以 null 結尾的 Unicode 字串值。 |
adVarBinary | 204 | 一個二進位制值 (僅用於 Parameter 物件)。 |
adLongVarBinary | 205 | 一個長二進位制值。 |
AdArray | 0x2000 | 一個標誌值,與另一個數據型別常量組合使用。表示該其他資料型別的陣列。 |
❮ 完整的欄位物件參考