ADO and SQL Server
Retrieving Connection Properties
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.
Examples
A. Retrieving the ConnectionTimeout, CommandTimeout, and Updatability properties.
The Properties collection is retrieved through the Connection, Command, and Recordset objects. The ConnectionTimeout property of the Connection object is then printed. The same steps are performed for the Command and Recordset objects.
This example demonstrates how to retrieve connection properties.
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New 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
' Retrieve the ConnectionTimeout property.
Debug.Print cn.Properties("ConnectionTimeout")
Set Cmd.ActiveConnection = Cn
cmd.CommandText = "titles"
cmd.CommandType = adCmdTable
Set rs = cmd.Execute
' Retrieve the CommandTimeout property.
Debug.Print cmd.Properties("CommandTimeout")
' Retrieve the Updatability property.
Debug.Print rs.Properties("Updatability")