RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TAdoDbxConnection Class

Represents a connection to a database.

Pascal
TAdoDbxConnection = class(DbConnection, ICloneable);
C++
class TAdoDbxConnection : public DbConnection, public ICloneable;

Borland.Data.AdoDbxClientProvider

TAdoDbxConnection represents a connection to a database. Upon creation of the object instance, all properties are set to their initial values. You must explicitly close any open connection using the Close method. There is no notion of an implicit disconnection in the .NET environment. 

TAdoDbxConnection is an implementation of the ADO.NET DbConnection class. 

To establish a database connection, you must create a new TAdoDbxConnection object and you must set its ConnectionString property. The ConnectionString is a name-value pair of all the parameters needed to connect to a particular database. 

TAdoDbxConnection has Open and Close methods to connect and disconnect from a database. The Open method uses the connection parameters specified in the ConnectionString property to establish a connection to a database. For every Open method, you should include a corresponding Close method. Otherwise, the connection might not be closed properly and any subsequent connection attempt will fail with an exception. 

A valid connection must be opened before you can use the TAdoDbxConnection to create a new TAdoDbxCommand or call BeginTransaction to create a new TAdoDbxTransaction instance. 

The following Delphi code shows the ConnectionString needed to connect to InterBase.

// Here is a simple way to connect to an “IBCONNECTION” connection from the dbxconnections.ini file:
 
    Factory := System.Data.Common.DbProviderFactories.GetFactory('Borland.Data.AdoDbxClient');
    Connection := Factory.CreateConnection();
    Connection.ConnectionString := 'ConnectionName=' + ‘IBCONNECTION’;
    Connection.Open;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!