ADO Object

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

The ADO object creates and accesses script objects that implement the same methods and properties as data-aware VCL objects (databases, tables, queries, etc.) by implementing an analogous OLE interface. These script objects implement the same properties and methods as underlying VCL objects for ADO access. For more information on these underlying VCL objects, see the documentation for ADODB classes.

In addition, the ADO object provides access to the Connection, Command and Recordset ADO objects. For more information on Microsoft ADO objects, see the ADO Objects and Interfaces article in the MSDN library.

Note that you can use the ADO object to execute only SQL queries (SELECT, UPDATE, INSERT, etc.), it does not allow executing SQLCMD scripts.

Note: To work with Microsoft ActiveX Data Objects from TestComplete, you can directly address the corresponding ADO component (e.g. CreateObject("ADODB.Connection")), or use the given ADO object (which is a wrapper for the respective VCL objects). Both approaches are analogous, however, you should not interchange them. Use either the ADO component or the VCL approach, but not both of them simultaneously.

Read the Using ADO Components and Working With Databases Using ADO and BDE Objects topics to learn more about these approaches.

The ADO object is a top-level object that is available only if the ADO Support plugin is installed.

In order for you to be able to use the ADO object, Microsoft Data Access Components ver. 2.1 or later must be installed on your computer. The components can be downloaded from Microsoft’s web site:

http://msdn2.microsoft.com/en-us/data/aa937730.aspx

Members

Example

The code below demonstrates how you can connect to the needed database by using the ADO object.

Notes:

JavaScript, JScript

function ADOExample()
 {
   // Create a Connection object
   var AConnection = ADO.CreateConnection();
   // Note that you can also create a connection using the following code:
   // var AConnection = CreateObject("ADODB.Connection")
  
   // Specify the connection string
   AConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
   "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
   // Open the database
   AConnection.Open();
   
   // ...
   
   // Close the connection
   AConnection.Close();
 }

Python

def ADOExample():
  # Create a Connection object 
  AConnection = ADO.CreateConnection()
  # Specify the connection string 
  AConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + \
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb"
  # Open the database 
  AConnection.Open()
  # Close the connection 
  AConnection.Close()

VBScript

Sub ADOExample
  ' Create a Connection object
  Set AConnection = ADO.CreateConnection
  ' Note that you can also create a connection using the following code:
  ' Set AConnection = CreateObject("ADODB.Connection")
 
  ' Specify the connection string
  AConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
  "Data Source=C:\Users\Public\Documents\TestComplete 14 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb"
  ' Open the database
  AConnection.Open
  
  ' ...
  
  ' Close the connection
  AConnection.Close
End Sub

DelphiScript

function ADOExample;
var AConnection;
begin
  // Create a Connection object
  AConnection := ADO.CreateConnection();
  // Note that you can also create a connection using the following code:
  // AConnection := CreateObject('ADODB.Connection')
 
  // Specify the connection string
  AConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
  'Data Source=C:\Users\Public\Documents\TestComplete 14 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb';
  // Open the database
  AConnection.Open();
  
  // ...
  
  // Close the connection
  AConnection.Close();
end;

C++Script, C#Script

function ADOExample()
{
  // Create a Connection object
  var AConnection = ADO["CreateConnection"]();
  // Note that you can also create a connection using the following code:
  // var AConnection = CreateObject("ADODB.Connection")
 
  // Specify the connection string
  AConnection["ConnectionString"] = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
  // Open the database
  AConnection["Open"]();
  
  // ...
  
  // Close the connection
  AConnection["Close"]();
}

See Also

ADO Support - Requirements
Working With Databases
TestComplete Helper Objects

Highlight search results