Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



ADO Field Object Type Property

The operational type or data type of a Field object.

Type Property Return Values (ADO Field Object)

Sets or returns one of the following DataTypeEnum values. The corresponding OLE DB type indicators are as follows:

Constant
Description
adArray
Or'd together with another type to indicate that the data is a safe-array of that type (DBTYPE_ARRAY).
adBigInt
An 8-byte signed integer (DBTYPE_I8).
adBinary
A binary value (DBTYPE_BYTES).
adBoolean
A Boolean value (DBTYPE_BOOL).
adByRef
Or'd together with another type to indicate that the data is a pointer to data of the other type (DBTYPE_BYREF).
adBSTR
A null-terminated character string (Unicode) (DBTYPE_BSTR).
adChar
A String value (DBTYPE_STR).
adCurrency
A currency value (DBTYPE_CY). Currency is a fixed-point number with 4 digits to the right of the decimal point. It is stored in an 8-byte signed integer scaled by 10,000.
adDate
A date value (DBTYPE_DATE). A date is stored as a Double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
adDBDate
A date value (yyyymmdd) (DBTYPE_DBDATE).
adDBTime
A time value (hhmmss) (DBTYPE_DBTIME).
adDBTimeStamp
A date-time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
adDecimal
An exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
adDouble
A double-precision floating point value (DBTYPE_R8).
adEmpty
No value was specified (DBTYPE_EMPTY).
adError
A 32-bit error code (DBTYPE_ERROR).
adGUID
A globally unique identifier (GUID) (DBTYPE_GUID).
adIDispatch
A pointer to an IDispatch interface on an OLE object (DBTYPE_IDISPATCH).
adInteger
A 4-byte signed integer (DBTYPE_I4).
adIUnknown
A pointer to an IUnknown interface on an OLE object (DBTYPE_IUNKNOWN).
adNumeric
An exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
adSingle
A single-precision floating point value (DBTYPE_R4).
adSmallInt
A 2-byte signed integer (DBTYPE_I2).
adTinyInt
A 1-byte signed integer (DBTYPE_I1).
adUnsignedBigInt
An 8-byte unsigned integer (DBTYPE_UI8).
adUnsignedInt
A 4-byte unsigned integer (DBTYPE_UI4).
adUnsignedSmallInt
A 2-byte unsigned integer (DBTYPE_UI2).
adUnsignedTinyInt
A 1-byte unsigned integer (DBTYPE_UI1).
adUserDefined
A user-defined variable (DBTYPE_UDT).
adVariant
An Automation Variant (DBTYPE_VARIANT).
adVector
OR'd together with another type to indicate that the data is a DBVECTOR structure, as defined by OLE DB, that contains a count of elements and a pointer to data of the other type (DBTYPE_VECTOR).
adWChar
A null-terminated Unicode character string (DBTYPE_WSTR).

Type Property Remarks (ADO Field Object)

For Field objects, the Type property is read-only.

Type Property Example (ADO Field Object)

This example demonstrates the Type property by displaying the name of the constant corresponding to the value of the Type property of all the Field objects in the Employees table. The FieldType function is required for this procedure to run.

Public Sub TypeX() 
Dim rstEmployees As ADODB.Recordset 
Dim fldLoop As ADODB.Field 
Dim strCnn As String
` Open recordset with data from Employee table. 
strCnn = "driver={SQL Server};server=srv;" & _ 
"uid=sa;pwd=;database=pubs" 
Set rstEmployees = New ADODB.Recordset 
rstEmployees.Open "employee", strCnn, , , adCmdTable
Debug.Print "Fields in Employee Table:" & vbCr
` Enumerate Fields collection of Employees table. 
For Each fldLoop In rstEmployees.Fields 
Debug.Print " Name: " & fldLoop.Name & vbCr & _ 
" Type: " & FieldType(fldLoop.Type) & vbCr 
Next fldLoop 
End Sub
Public Function FieldType(intType As Integer) As String 
Select Case intType 
Case adChar 
FieldType = "adChar" 
Case adVarChar 
FieldType = "adVarChar" 
Case adSmallInt 
FieldType = "adSmallInt" 
Case adUnsignedTinyInt 
FieldType = "adUnsignedTinyInt" 
Case adDBTimeStamp 
FieldType = "adDBTimeStamp" 
End Select 
End Function


ContentsPreviousNextIndex