Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Determining the Characteristics of a Result Set

SQL Server 2000

The Properties collection and Property object provide information about the characteristics of the Connection, Command, Recordset, and Field objects. The Properties collection can be accessed through any of these objects, and the Property object can be accessed through the Properties collection by using the default indexing method.

The Properties collection consists of Property objects. In addition to returning the value and type for a property, the Property object provides attributes of a property. Attributes describe things such as whether the specific property of an object is supported or required, or whether it is read/write or read-only. For example, ConnectionTimeout is a property that provides information about the number of seconds to wait to establish a connection before returning a time-out error.

Examples
Enumerating Through the Properties Collection for an Object.

The following code shows a method for listing each property of an object, using a Connection object and Recordset object as examples.

Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset

cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = "MyServerName"
cn.Properties("Initial Catalog").Value = "northwind"
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open

Set rs = New ADODB.Recordset
rs.Open "select * from products", cn

' Create a variable to list the properties.
Dim prop As ADODB.Property

' Enumerate through the properties of the Connection object.
For Each prop In cn.Properties
   Debug.Print prop.Name, prop.Value, prop.Attributes
Next

' Enumerate through the properties of the Recordset object.
For Each prop In rs.Properties
   Debug.Print prop.Name, prop.Value, prop.Attributes
Next
Show:
© 2015 Microsoft