RAD Studio |  |

Connecting an ADO Dataset to a Data Store
See Also
Collapse All

ADO datasets can connect to an ADO data store either collectively or individually.

When connecting datasets collectively, set the Connection property of each dataset to a TADOConnection component. Each dataset then uses the ADO connection component's connection.

Copy Code

    ADODataSet1.Connection := ADOConnection1;
    ADODataSet2.Connection := ADOConnection1;
    ...

Copy Code

    ADODataSet1->Connection = ADOConnection1;
    ADODataSet2->Connection = ADOConnection1;
    ...

Among the advantages of connecting datasets collectively are:

- The datasets share the connection object's attributes.
- Only one connection need be set up: that of the TADOConnection.
- The datasets can participate in transactions.

For more information on using TADOConnection see Connecting to ADO data stores.

When connecting datasets individually, set the ConnectionString property of each dataset. Each dataset that uses ConnectionString establishes its own connection to the data store, independent of any other dataset connection in the application.

The ConnectionString property of ADO datasets works the same way as the ConnectionString property of TADOConnection: it is a set of semicolon-delimited connection parameters such as the following:

Copy Code

    ADODataSet1.ConnectionString := "Provider=YourProvider;Password=SecretWord;" +
      "User ID=JaneDoe;SERVER=PURGATORY;UID=JaneDoe;PWD=SecretWord;" +
      "Initial Catalog=Employee";

Copy Code

    ADODataSet1->ConnectionString = "Provider=YourProvider;Password=SecretWord;";
    ADODataSet1->ConnectionString += "User ID=JaneDoe;SERVER=PURGATORY";
    ADODataSet1->ConnectionString += "UID=JaneDoe;PWD=SecretWord;"
    ADODataSet1->ConnectionString += "Initial Catalog=Employee";

At design time you can use the Connection String Editor to help you build the connection string. For more information about connection strings, see Connecting to a data store using TADOConnection.

See Also

Filtering Records Based On Bookmarks

Working with Record Sets

Using Batch Updates

Loading Data from and Saving Data to Files

Fetching Records Asynchronously

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!