Connecting an ADO Dataset to a Data Store

From RAD Studio
Jump to: navigation, search

Go Up to Using ADO datasets


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 connection of the ADO connection component.

ADODataSet1.Connection := ADOConnection1;
ADODataSet2.Connection := ADOConnection1;
...
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:

ADODataSet1.ConnectionString := "Provider=YourProvider;Password=SecretWord;" +
  "User ID=JaneDoe;SERVER=PURGATORY;UID=JaneDoe;PWD=SecretWord;" +
  "Initial Catalog=Employee";
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.

Topics