Connection Properties

You can programmatically access the information about the available connection properties and those set in the connection string by querying the ConnectionProperties schema collection.

Retrieving Connection Property Information

To retrieve the ConnectionProperties schema collection, call the GetSchema method of the CompositeConnection class. Access the results in the DataTable returned.

 

C#

 

DbProviderFactory provider = DbProviderFactories.GetFactory("System.Data.CompositeClient");
using(DbConnection conn = provider.CreateConnection()) {
  conn.Open();
  DataTable databaseSchema = conn.GetSchema("ConnectionProperties");
  foreach (DataRow row in databaseSchema.Rows) {
    Console.WriteLine(row["Name"]);
    Console.WriteLine(row["Type"]);
    Console.WriteLine(row["ShortDescription"]);
  }
}

VB.NET

 

Dim provider = DbProviderFactories.GetFactory("System.Data.CompositeClient")
Using conn As DbConnection = provider.CreateConnection()
  conn.Open()
  Dim databaseSchema As DataTable = conn.GetSchema("ConnectionProperties")
    For Each row As DataRow In databaseSchema.Rows
    Console.WriteLine(row("Name"))
    Console.WriteLine(row("Type"))
    Console.WriteLine(row("ShortDescription"))
  Next
End Using

Columns Returned

The ConnectionProperties schema collection contains the following information:

Column Name

Data Type

Description

Name

System.String

The name of the connection property.

ShortDescription

System.String

A description of the connection property.

Type

System.String

The data type.

Values

System.String

The allowed values.

Default

System.String

The default value if one is not set by the user.

Category

System.String

A category grouping associated connection properties.

Required

System.String

Whether the property is required to connect.

Value

System.String

The current value of the connection property.