Attributes, Name Properties Example

This examples displays the value of the Attributes property for Connection, Field, and Property objects. It uses the Name property to display the name of each Field and Property object.

Public Sub AttributesX

	Dim cnn1 As ADODB.Connection
	Dim rstEmployees As ADODB.Recordset
	Dim fldLoop As ADODB.Field
	Dim proLoop As ADODB.Property
	Dim strCnn As String
	
	' Open connection and recordset.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	Set cnn1 = New ADODB.Connection
	cnn1.Open strCnn
	Set rstEmployees = New ADODB.Recordset
	rstEmployees.Open "employee", cnn1
	
	' Display the attributes of the connection.
	Debug.Print "Connection attributes = " & cnn1.Attributes

	With rstEmployees

		' Display the attributes of the Employee table's
		' fields.
		Debug.Print "Field attributes:"
		For Each fldLoop In .Fields
			Debug.Print "	" & fldLoop.Name & " = " & _
				fldLoop.Attributes
		Next fldLoop

		' Display the attributes of the Employee table's
		' properties.
		Debug.Print "Property attributes:"
		For Each proLoop In .Properties
			Debug.Print "	" & proLoop.Name & " = " & _
				proLoop.Attributes
		Next proLoop

		.Close
	End With
	
	cnn1.Close

End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.