The following code may be used to derive details about the name, value and type for each column in the current row of a database table.
<% Dim objFields As ADODB.Fields Dim i As Integer objRs.Open strSQL, strConnStr, adOpenForwardOnly, adLockReadOnly, adCmdText Set objFields = objRS.Fields For Each fieldF in objRS.Fields fieldName = fieldF.Name fieldType = fieldF.Type fieldValue = fieldF.Value Next %>
Where objRS is the database SQL statement and this piece of code is wrapped in a do while loop.
The information returned relating to the field type is not in an easily understood form. Given below is a table of field types with their corresponding returned integer value.
| Value | Column Type |
|---|---|
| 0 | Empty |
| 2 | SmallInt |
| 3 | Integer |
| 4 | Single |
| 5 | Double |
| 6 | Currency |
| 7 | Date |
| 8 | BSTR |
| 9 | IDispatch |
| 10 | Error |
| 11 | Boolean |
| 12 | Variant |
| 13 | IUnknown |
| 14 | Decimal |
| 16 | TinyInt |
| 17 | UnsignedTinyInt |
| 18 | UnsignedSmallInt |
| 19 | UnsignedInt |
| 20 | BigInt |
| 21 | UnsignedBigInt |
| 64 | FileTime |
| 72 | GUID |
| 128 | Binary |
| 129 | Char |
| 130 | WChar |
| 131 | WChar Numeric |
| 132 | UserDefined |
| 133 | DBDate |
| 134 | DBTime |
| 135 | DBTimeStamp |
| 136 | Chapter |
| 138 | PropVariant |
| 139 | VarNumeric |
| 200 | VarChar |
| 201 | LongVarChar |
| 202 | VarWChar |
| 203 | LongVarWChar |
| 204 | VarBinary |
| 205 | LongVarBinary |
| &H2000 | Array |


