ADO Property Object
The ADO Property object contains a provider-specific property.
Each provider that talks (connect) with ADO has different ways of interacting
with ADO. Therefore, ADO needs to store information about the provider in some
way. The solution is that the provider gives specific information called dynamic
properties, to ADO. ADO stores each provider property in a Property object and
then stores each object in the Properties Collection that is assigned to the ADO
object. The Collection is assigned to either a Command object, Connection
object, Field object, or a Recordset object. These are the four ADO objects that
have a Properties Collection.
Properties
Property |
Description |
Attributes |
Returns the attributes of a Property object |
Name |
Sets or returns the name of a Property object |
Type |
Returns the type of a Property object |
Value |
Sets or returns the value of a Property object |
Attributes
Syntax: long
= propertyobject.Attributes
The Attributes property returns a
long value that is the sum of one or more of the ParameterAttributesEnum
constants that indicate the characteristics of a Property object.
Not all providers support this property.
PropertyAttributesEnum Constants
Constant |
Value |
Description |
adPropNotSupported |
0 |
Not supported by provider |
adPropRequired |
1 |
Property must be specified before data source is initialized |
adPropOptional |
2 |
Property does not have to be specified before data source is
initialized |
adPropRead |
512 |
User can read property |
adPropWrite |
1024 |
User can set property |
Example:
If (objConnection.Properties(strName).Attributes
= adPropNotSupported) Then
debug.print "WARNING: Not supported by provider"
End If
Name
Syntax: string = fieldobject.Name
Sets or returns a string value that is the
name of the Property object.
The Name property returns a string
that is the name of the Property object. The name can also be obtained
from the Properties Collection.
The Name property is also used by the Command, Field, and
Parameter objects.
Example:
For Each objProperty In
objConnection.Properties
debug.print
"Name = " & objProperty.Name
& VbCrLf
debug.print
"Type = " & objProperty.Type & VbCrLf
debug.print
"Value = " & objProperty.Value & VbCrLf
Next
Type
Syntax: DataTypeEnum = propertyobject.Type
Sets or returns a DataTypeEnum value
that specifies the data type.
The Type property returns a
DataTypeEnum value which is the data type or operational type of the
Property object.
Unfortunately, some providers may not support all of the possible data types. If
a provider encounters a data type that it does not recognize, it will usually
change it to a data type that it does recognize.
Example:
For Each objProperty In
objConnection.Properties
debug.print "Name = " & objProperty.Name & VbCrLf
debug.print "Type = " & objProperty.Type
& VbCrLf
debug.print "Value = " & objProperty.Value & VbCrLf
Next
DataTypeEnum Constants
Constant |
Value |
Description |
adArray |
0x2000 |
Combine with another data type to indicate that the other data type
is an array |
adBigInt |
20 |
8-byte signed integer |
adBinary |
128 |
Binary |
adBoolean |
11 |
True or false Boolean |
adBSTR |
8 |
Null-terminated character string |
adChapter |
136 |
4-byte chapter value for a child recordset |
adChar |
129 |
String |
adCurrency |
6 |
Currency format |
adDate |
7 |
Number of days since 12/30/1899 |
adDBDate |
133 |
YYYYMMDD date format |
adDBFileTime |
137 |
Database file time |
adDBTime |
134 |
HHMMSS time format |
adDBTimeStamp |
135 |
YYYYMMDDHHMMSS date/time format |
adDecimal |
14 |
Number with fixed precision and scale |
adDouble |
5 |
Double precision floating-point |
adEmpty |
0 |
no value |
adError |
10 |
32-bit error code |
adFileTime |
64 |
Number of 100-nanosecond intervals since 1/1/1601 |
adGUID |
72 |
Globally Unique identifier |
adIDispatch |
9 |
Currently not supported by ADO |
adInteger |
3 |
4-byte signed integer |
adIUnknown |
13 |
Currently not supported by ADO |
adNumeric |
131 |
Number with fixed precision and scale |
adPropVariant |
138 |
PROPVARIANT automation |
adSingle |
4 |
Single-precision floating-point value |
adSmallInt |
2 |
2-byte signed integer |
adTinyInt |
16 |
1-byte signed integer |
adUnsignedBigInt |
21 |
8-byte unsigned integer |
adUnsignedInt |
19 |
4-byte unsigned integer |
adUnsignedSmallInt |
18 |
2-byte unsigned integer |
adUnsignedTinyInt |
17 |
1-byte unsigned integer |
adUserDefined |
132 |
User-defined variable |
adVariant |
12 |
Automation variant |
adWChar |
130 |
Null-terminated Unicode character string |
Value
Syntax: variant = propertyobject.Value
propertyobject.Value = variant
Sets or returns a variant that is the value
of the Property object.
The Value property sets or returns a
variant that is the current value of the Property object.
Properties can be set to read or write by using the Attributes property.
You will not be able to set the Value for properties that are read-only.
Example:
If (objConnection.Properties(strName).Attributes
= adPropWrite) Then
objConnection.Properties(strName).Value
= intCount
Else
debug.print "WARNING: Cannot set value for " & strName & VBCRLF
End If
|