ComponentOne DataObjects for .NET
DynamicConnections Property

C1.Data.2 Assembly > C1.Data Namespace > C1DataSet Class : DynamicConnections Property
Gets a collection of Connection objects used at run time as substitutes for schema connections.
Syntax
'Declaration
 
Public ReadOnly Property DynamicConnections As ConnectionCollection
public ConnectionCollection DynamicConnections {get;}
Remarks
This property changes connection at run time for a single data set. If you need to change schema connection for all data sets at once, set Connection.ConnectionString in the CreateSchema event.

By default, if C1DataSet.DynamicConnections is empty, data fetch and update for this data set uses the connections specified in the schema.

Add a connection object for each connection you want to change at run time for this data set. Usually, you will add a copy of a schema connection object(s) using C1.Data.SchemaObjects.Connection.Clone. Alternatively, you can create new connection objects from scratch, for example, new C1.Data.SchemaObjects.C1OleDbConnection(). Adding an existing connection object from schema to DynamicConnections throws an exception. This prevents changes unintentionally affecting other data sets attached to the same schema.

Having added a connection object, set its properties as desired. Usually, only the C1.Data.SchemaObjects.Connection.ConnectionString needs to be changed in connection objects obtained with C1.Data.SchemaObjects.Connection.Clone. If you created a new connection object, without using C1.Data.SchemaObjects.Connection.Clone, set its C1.Data.SchemaObjects.Connection.Name property to the name of the schema connection you want to modify.

When the data set performs a fetch or update operation while its DynamicConnections collection is not empty, it first looks for connection properties in DynamicConnection, and only then, if not found, in the schema. If DynamicConnections contains a connection with the same C1.Data.SchemaObjects.Connection.Name as the schema connection, that DynamicConnections element is used instead of the schema connection.

See Also

Reference

C1DataSet Class
C1DataSet Members
Database Connections